fix bug in path_expand() when passed an empty string
[ardour.git] / libs / ardour / session_process.cc
index 5c67b6b2993a44d0c2cdc2d29330fc80a8687fa8..b18e00f9fd7f1271805428f44c857bfd0b68dfd8 100644 (file)
@@ -37,7 +37,7 @@
 #include "ardour/slave.h"
 #include "ardour/timestamps.h"
 #include "ardour/graph.h"
-#include "ardour/port.h"
+#include "ardour/audio_port.h"
 
 #include "midi++/manager.h"
 #include "midi++/mmc.h"
@@ -69,10 +69,6 @@ Session::process (nframes_t nframes)
                }
        }
 
-        if (_mmc) {
-                _mmc->flush_pending ();
-        }
-        
         _engine.main_thread()->get_buffers ();
 
        (this->*process_function) (nframes);
@@ -237,12 +233,12 @@ Session::get_track_statistics ()
 void
 Session::process_with_events (nframes_t nframes)
 {
-       SessionEvent*         ev;
+       SessionEvent*  ev;
        nframes_t      this_nframes;
-       nframes_t      end_frame;
+       framepos_t     end_frame;
        bool           session_needs_butler = false;
-       nframes_t      stop_limit;
-       long           frames_moved;
+       framepos_t     stop_limit;
+       framecnt_t     frames_moved;
 
        /* make sure the auditioner is silent */
 
@@ -272,7 +268,7 @@ Session::process_with_events (nframes_t nframes)
         * on locates (and allow slow slaves to position and prepare for rolling)
         */
        if (_send_timecode_update) {
-               send_full_time_code(nframes);
+               send_full_time_code (_transport_frame);
        }
 
        if (!process_can_proceed()) {
@@ -286,11 +282,11 @@ Session::process_with_events (nframes_t nframes)
        }
 
        if (_transport_speed == 1.0) {
-               frames_moved = (long) nframes;
+               frames_moved = (framecnt_t) nframes;
        } else {
                interpolation.set_target_speed (fabs(_target_transport_speed));
                interpolation.set_speed (fabs(_transport_speed));
-               frames_moved = (long) interpolation.interpolate (0, nframes, 0, 0);
+               frames_moved = (framecnt_t) interpolation.interpolate (0, nframes, 0, 0);
        }
 
        end_frame = _transport_frame + (nframes_t)frames_moved;
@@ -315,18 +311,18 @@ Session::process_with_events (nframes_t nframes)
                        return;
                }
 
-               if (!_exporting) {
+               if (!_exporting && !timecode_transmission_suspended()) {
                        send_midi_time_code_for_cycle (nframes);
                }
 
                if (actively_recording()) {
-                       stop_limit = max_frames;
+                       stop_limit = max_framepos;
                } else {
 
                        if (Config->get_stop_at_session_end()) {
                                stop_limit = current_end_frame();
                        } else {
-                               stop_limit = max_frames;
+                               stop_limit = max_framepos;
                        }
                }
 
@@ -346,12 +342,12 @@ Session::process_with_events (nframes_t nframes)
                while (nframes) {
 
                        this_nframes = nframes; /* real (jack) time relative */
-                       frames_moved = (long) floor (_transport_speed * nframes); /* transport relative */
+                       frames_moved = (framecnt_t) floor (_transport_speed * nframes); /* transport relative */
 
                        /* running an event, position transport precisely to its time */
                        if (this_event && this_event->action_frame <= end_frame && this_event->action_frame >= _transport_frame) {
                                /* this isn't quite right for reverse play */
-                               frames_moved = (long) (this_event->action_frame - _transport_frame);
+                               frames_moved = (framecnt_t) (this_event->action_frame - _transport_frame);
                                this_nframes = (nframes_t) abs( floor(frames_moved / _transport_speed) );
                        }
 
@@ -439,7 +435,7 @@ bool
 Session::follow_slave (nframes_t nframes)
 {
        double slave_speed;
-       nframes64_t slave_transport_frame;
+       framepos_t slave_transport_frame;
        nframes_t this_delta;
        int dir;
 
@@ -574,7 +570,7 @@ Session::calculate_moving_average_of_slave_delta(int dir, nframes_t this_delta)
        }
 
        if (delta_accumulator_cnt != 0 || this_delta < _current_frame_rate) {
-               delta_accumulator[delta_accumulator_cnt++] = long(dir) * long(this_delta);
+               delta_accumulator[delta_accumulator_cnt++] = (nframes_t) dir *  (nframes_t) this_delta;
        }
 
        if (have_first_delta_accumulator) {
@@ -582,7 +578,7 @@ Session::calculate_moving_average_of_slave_delta(int dir, nframes_t this_delta)
                for (int i = 0; i < delta_accumulator_size; ++i) {
                        average_slave_delta += delta_accumulator[i];
                }
-               average_slave_delta /= long(delta_accumulator_size);
+               average_slave_delta /= (int32_t) delta_accumulator_size;
                if (average_slave_delta < 0L) {
                        average_dir = -1;
                        average_slave_delta = abs(average_slave_delta);
@@ -612,7 +608,7 @@ Session::track_slave_state (float slave_speed, nframes_t slave_transport_frame,
 
                                _slave_state = Running;
 
-                               Location* al = _locations.auto_loop_location();
+                               Location* al = _locations->auto_loop_location();
 
                                if (al && play_loop && (slave_transport_frame < al->start() || slave_transport_frame > al->end())) {
                                        // cancel looping
@@ -671,7 +667,7 @@ Session::track_slave_state (float slave_speed, nframes_t slave_transport_frame,
                                        /* XXX what? */
                                }
 
-                               memset (delta_accumulator, 0, sizeof (long) * delta_accumulator_size);
+                               memset (delta_accumulator, 0, sizeof (int32_t) * delta_accumulator_size);
                                average_slave_delta = 0L;
                                this_delta = 0;
                        }
@@ -726,16 +722,16 @@ Session::follow_slave_silently (nframes_t nframes, float slave_speed)
                } else {
                        increment_transport_position (frames_moved);
                }
-
-               nframes_t stop_limit;
+                
+               framepos_t stop_limit;
 
                if (actively_recording()) {
-                       stop_limit = max_frames;
+                       stop_limit = max_framepos;
                } else {
                        if (Config->get_stop_at_session_end()) {
                                stop_limit = current_end_frame();
                        } else {
-                               stop_limit = max_frames;
+                               stop_limit = max_framepos;
                        }
                }
 
@@ -747,8 +743,8 @@ void
 Session::process_without_events (nframes_t nframes)
 {
        bool session_needs_butler = false;
-       nframes_t stop_limit;
-       long frames_moved;
+       framepos_t stop_limit;
+       framecnt_t frames_moved;
 
        if (!process_can_proceed()) {
                _silent = true;
@@ -766,17 +762,17 @@ Session::process_without_events (nframes_t nframes)
                return;
        }
 
-       if (!_exporting) {
+       if (!_exporting && !timecode_transmission_suspended()) {
                send_midi_time_code_for_cycle (nframes);
        }
 
        if (actively_recording()) {
-               stop_limit = max_frames;
+               stop_limit = max_framepos;
        } else {
                if (Config->get_stop_at_session_end()) {
                        stop_limit = current_end_frame();
                } else {
-                       stop_limit = max_frames;
+                       stop_limit = max_framepos;
                }
        }
 
@@ -792,11 +788,11 @@ Session::process_without_events (nframes_t nframes)
        click (_transport_frame, nframes);
 
        if (_transport_speed == 1.0) {
-               frames_moved = (long) nframes;
+               frames_moved = (framecnt_t) nframes;
        } else {
                interpolation.set_target_speed (fabs(_target_transport_speed));
                interpolation.set_speed (fabs(_transport_speed));
-               frames_moved = (long) interpolation.interpolate (0, nframes, 0, 0);
+               frames_moved = (framecnt_t) interpolation.interpolate (0, nframes, 0, 0);
        }
 
        if (process_routes (nframes, session_needs_butler)) {
@@ -888,7 +884,7 @@ Session::maybe_sync_start (nframes_t& nframes)
 
                no_roll (sync_offset);
                nframes -= sync_offset;
-               Port::increment_port_offset (sync_offset);
+               AudioPort::increment_port_offset (sync_offset);
                waiting_for_sync_offset = false;
 
                if (nframes == 0) {
@@ -1103,6 +1099,10 @@ Session::process_event (SessionEvent* ev)
                 schedule_capture_buffering_adjustment ();
                 break;
 
+       case SessionEvent::SetTimecodeTransmission:
+               g_atomic_int_set (&_suspend_timecode_transmission, ev->yes_or_no ? 0 : 1);
+               break;
+
        default:
          fatal << string_compose(_("Programming error: illegal event type in process_event (%1)"), ev->type) << endmsg;
                /*NOTREACHED*/