Merge branch 'patch-1' of https://github.com/globin/ardour
[ardour.git] / libs / ardour / session_process.cc
index 4af6b10b89c840b36d1ead9dac1c8ba35ba7c1d1..067a91da48f45449933c1960cdc3482fe7681e3e 100644 (file)
@@ -116,6 +116,8 @@ Session::no_roll (pframes_t nframes)
                _click_io->silence (nframes);
        }
 
+       ltc_tx_send_time_code_for_cycle (_transport_frame, end_frame, _target_transport_speed, _transport_speed, nframes);
+
        if (_process_graph) {
                DEBUG_TRACE(DEBUG::ProcessThreads,"calling graph/no-roll\n");
                _process_graph->routes_no_roll( nframes, _transport_frame, end_frame, non_realtime_work_pending(), declick);
@@ -123,7 +125,7 @@ Session::no_roll (pframes_t nframes)
                PT_TIMING_CHECK (10);
                for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
 
-                       if ((*i)->is_hidden()) {
+                       if ((*i)->is_auditioner()) {
                                continue;
                        }
 
@@ -168,7 +170,7 @@ Session::process_routes (pframes_t nframes, bool& need_butler)
 
                        int ret;
 
-                       if ((*i)->is_hidden()) {
+                       if ((*i)->is_auditioner()) {
                                continue;
                        }
 
@@ -208,7 +210,7 @@ Session::silent_process_routes (pframes_t nframes, bool& need_butler)
 
                        int ret;
 
-                       if ((*i)->is_hidden()) {
+                       if ((*i)->is_auditioner()) {
                                continue;
                        }
 
@@ -341,8 +343,8 @@ Session::process_with_events (pframes_t nframes)
        if (_transport_speed == 1.0) {
                frames_moved = (framecnt_t) nframes;
        } else {
-               interpolation.set_target_speed (fabs(_target_transport_speed));
-               interpolation.set_speed (fabs(_transport_speed));
+               interpolation.set_target_speed (_target_transport_speed);
+               interpolation.set_speed (_transport_speed);
                frames_moved = (framecnt_t) interpolation.interpolate (0, nframes, 0, 0);
        }
 
@@ -513,7 +515,9 @@ Session::follow_slave (pframes_t nframes)
                slave_speed = 0.0f;
        }
 
-       if (_slave->is_always_synced() || Config->get_timecode_source_is_synced()) {
+       if (_slave->is_always_synced() ||
+                       (Config->get_timecode_source_is_synced() && (dynamic_cast<TimecodeSlave*>(_slave)) != 0)
+                       ) {
 
                /* if the TC source is synced, then we assume that its
                   speed is binary: 0.0 or 1.0
@@ -541,7 +545,9 @@ Session::follow_slave (pframes_t nframes)
                                                   _slave_state, slave_transport_frame, slave_speed, this_delta, average_slave_delta));
 
 
-       if (_slave_state == Running && !_slave->is_always_synced() && !Config->get_timecode_source_is_synced()) {
+       if (_slave_state == Running && !_slave->is_always_synced() &&
+                       !(Config->get_timecode_source_is_synced() && (dynamic_cast<TimecodeSlave*>(_slave)) != 0)
+                       ) {
 
                if (_transport_speed != 0.0f) {
 
@@ -666,6 +672,7 @@ Session::track_slave_state (float slave_speed, framepos_t slave_transport_frame,
                                }
 
                                if (slave_transport_frame != _transport_frame) {
+                                       DEBUG_TRACE (DEBUG::Slave, string_compose ("require locate to run. eng: %1 -> sl: %2\n", _transport_frame, slave_transport_frame));
                                        locate (slave_transport_frame, false, false);
                                }
                                _slave_state = Running;
@@ -788,6 +795,7 @@ Session::process_without_events (pframes_t nframes)
 
        if (!_exporting && _slave) {
                if (!follow_slave (nframes)) {
+                       ltc_tx_send_time_code_for_cycle (_transport_frame, _transport_frame, 0, 0 , nframes);
                        return;
                }
        }
@@ -800,8 +808,8 @@ Session::process_without_events (pframes_t nframes)
        if (_transport_speed == 1.0) {
                frames_moved = (framecnt_t) nframes;
        } else {
-               interpolation.set_target_speed (fabs(_target_transport_speed));
-               interpolation.set_speed (fabs(_transport_speed));
+               interpolation.set_target_speed (_target_transport_speed);
+               interpolation.set_speed (_transport_speed);
                frames_moved = (framecnt_t) interpolation.interpolate (0, nframes, 0, 0);
        }
 
@@ -809,6 +817,8 @@ Session::process_without_events (pframes_t nframes)
                send_midi_time_code_for_cycle (_transport_frame, _transport_frame + frames_moved, nframes);
        }
 
+       ltc_tx_send_time_code_for_cycle (_transport_frame, _transport_frame + frames_moved, _target_transport_speed, _transport_speed, nframes);
+
        framepos_t const stop_limit = compute_stop_limit ();
 
        if (maybe_stop (stop_limit)) {
@@ -829,16 +839,6 @@ Session::process_without_events (pframes_t nframes)
 
        get_track_statistics ();
 
-       /* XXX: I'm not sure whether this is correct, but at least it
-          matches process_with_events, so that this new frames_moved
-          is -ve when transport speed is -ve.  This means that the
-          transport position is updated correctly when we are in
-          reverse.  It seems a bit wrong that we're not using the
-          interpolator to compute this.
-       */
-
-       frames_moved = (framecnt_t) floor (_transport_speed * nframes);
-
        if (frames_moved < 0) {
                decrement_transport_position (-frames_moved);
        } else {
@@ -863,7 +863,7 @@ Session::process_audition (pframes_t nframes)
        boost::shared_ptr<RouteList> r = routes.reader ();
 
        for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
-               if (!(*i)->is_hidden()) {
+               if (!(*i)->is_auditioner()) {
                        (*i)->silence (nframes);
                }
        }
@@ -877,7 +877,7 @@ Session::process_audition (pframes_t nframes)
        /* if using a monitor section, run it because otherwise we don't hear anything */
 
        if (auditioner->needs_monitor()) {
-               _monitor_out->passthru (_transport_frame, _transport_frame + nframes, nframes, false);
+               _monitor_out->monitor_run (_transport_frame, _transport_frame + nframes, nframes, false);
        }
 
        /* handle pending events */
@@ -1177,6 +1177,11 @@ Session::compute_stop_limit () const
        if (!Config->get_stop_at_session_end ()) {
                return max_framepos;
        }
+
+       if (_slave) {
+               return max_framepos;
+       }
+
        
        bool const punching_in = (config.get_punch_in () && _locations->auto_punch_location());
        bool const punching_out = (config.get_punch_out () && _locations->auto_punch_location());