Fix MTC slave implicit return on transport-stop
authorRobin Gareus <robin@gareus.org>
Tue, 10 Jan 2017 09:38:00 +0000 (10:38 +0100)
committerRobin Gareus <robin@gareus.org>
Tue, 10 Jan 2017 09:39:22 +0000 (10:39 +0100)
MTC returns not-locked (no flywheel) when the signal is lost, in which case
Session::follow_slave() jumps to no_roll and ignores the slave-position.
The MTC slave does explicitly request a transport-locate and transport-stop.

Yet, Session::realtime_stop() honors _requested_return_frame for whatever
reason

libs/ardour/mtc_slave.cc
libs/ardour/session_transport.cc

index 5eda7e14a52c6ebe13c5e1550c799d479abfcf2c..cbb97cf1ad25f6dd21419733c798dedbbad6d06b 100644 (file)
@@ -426,9 +426,10 @@ MTC_Slave::update_mtc_time (const MIDI::byte *msg, bool was_full, framepos_t now
                                                 now, timecode, mtc_frame, was_full, speedup_due_to_tc_mismatch));
 
        if (was_full || outside_window (mtc_frame)) {
-               DEBUG_TRACE (DEBUG::MTC, string_compose ("update_mtc_time: full TC %1 or outside window %2\n", was_full, outside_window (mtc_frame)));
-               session.request_locate (mtc_frame, false);
+               DEBUG_TRACE (DEBUG::MTC, string_compose ("update_mtc_time: full TC %1 or outside window %2 MTC %3\n", was_full, outside_window (mtc_frame), mtc_frame));
+               session.set_requested_return_frame (-1);
                session.request_transport_speed (0);
+               session.request_locate (mtc_frame, false);
                update_mtc_status (MIDI::MTC_Stopped);
                reset (false);
                reset_window (mtc_frame);
@@ -491,7 +492,7 @@ MTC_Slave::update_mtc_status (MIDI::MTC_Status status)
        /* XXX !!! thread safety ... called from MIDI I/O context
         * on locate (via ::update_mtc_time())
         */
-       DEBUG_TRACE (DEBUG::MTC, string_compose("MTC_Slave::update_mtc_status - TID:%1\n", pthread_name()));
+       DEBUG_TRACE (DEBUG::MTC, string_compose("MTC_Slave::update_mtc_status - TID:%1 MTC:%2\n", pthread_name(), mtc_frame));
        return; // why was this fn needed anyway ? it just messes up things -> use reset.
        busy_guard1++;
 
@@ -624,12 +625,13 @@ MTC_Slave::speed_and_position (double& speed, framepos_t& pos)
        if (last_inbound_frame && now > last_inbound_frame && now - last_inbound_frame > labs(seekahead_distance())) {
                speed = 0;
                pos = last.position;
+               session.set_requested_return_frame (-1);
                session.request_locate (pos, false);
                session.request_transport_speed (0);
                engine_dll_initstate = 0;
                queue_reset (false);
-        ActiveChanged (false);
-               DEBUG_TRACE (DEBUG::MTC, "MTC not seen for 2 frames - reset pending\n");
+               ActiveChanged (false);
+               DEBUG_TRACE (DEBUG::MTC, string_compose ("MTC not seen for 2 frames - reset pending, pos = %1\n", pos));
                return false;
        }
 
index 68e6f49342abc2ddd217b6f9e0d9ecbb4be9faf9..5f1384d29218a6b70d25dceee60eb77826ba4d93 100644 (file)
@@ -746,6 +746,10 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished)
                        flush_all_inserts ();
                }
 
+               // rg: what is the logic behind this case?
+               // _requested_return_frame should be ignored when synced_to_engine/slaved.
+               // currently worked around in MTC_Slave by forcing _requested_return_frame to -1
+               // 2016-01-10
                if ((auto_return_enabled || synced_to_engine() || _requested_return_frame >= 0) &&
                    !(ptw & PostTransportLocate)) {