sort of no-op ... remove debug output ... just basically put it in git so that i...
[ardour.git] / libs / ardour / session_transport.cc
index f8f241d11ab8805453fb40f7b533db9a2416176d..f09f3ac2538d2e2bc60571ac646901472d793fbb 100644 (file)
@@ -41,6 +41,7 @@
 #include "ardour/butler.h"
 #include "ardour/click.h"
 #include "ardour/debug.h"
+#include "ardour/disk_reader.h"
 #include "ardour/location.h"
 #include "ardour/profile.h"
 #include "ardour/scene_changer.h"
@@ -76,15 +77,6 @@ Session::add_post_transport_work (PostTransportWork ptw)
        error << "Could not set post transport work! Crazy thread madness, call the programmers" << endmsg;
 }
 
-void
-Session::request_input_change_handling ()
-{
-       if (!(_state_of_the_state & (InitialConnecting|Deletion))) {
-               SessionEvent* ev = new SessionEvent (SessionEvent::InputConfigurationChange, SessionEvent::Add, SessionEvent::Immediate, 0, 0.0);
-               queue_event (ev);
-       }
-}
-
 void
 Session::request_sync_source (Slave* new_slave)
 {
@@ -523,8 +515,7 @@ Session::butler_transport_work ()
 
        g_atomic_int_dec_and_test (&_butler->should_do_transport_work);
 
-       DEBUG_TRACE (DEBUG::Transport, string_compose (X_("Butler transport work all done after %1 usecs\n"), g_get_monotonic_time() - before));
-       DEBUG_TRACE (DEBUG::Transport, X_(string_compose ("Frame %1\n", _transport_frame)));
+       DEBUG_TRACE (DEBUG::Transport, string_compose (X_("Butler transport work all done after %1 usecs @ %2 trw = %3\n"), g_get_monotonic_time() - before, _transport_frame, _butler->transport_work_requested()));
 }
 
 void
@@ -592,19 +583,46 @@ Session::non_realtime_locate ()
        }
 
 
+       microseconds_t begin = get_microseconds ();
+       framepos_t tf;
+
        {
                boost::shared_ptr<RouteList> rl = routes.reader();
+
+         restart:
+               gint sc = g_atomic_int_get (&_seek_counter);
+               tf = _transport_frame;
+
+               cerr << "\n\n >>> START Non-RT locate on routes to " << tf << " counter = " << sc << "\n\n";
+
                for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
-                       (*i)->non_realtime_locate (_transport_frame);
+                       (*i)->non_realtime_locate (tf);
+                       //::usleep (250000);
+                       cerr << "\t\tcounter after track: " << g_atomic_int_get (&_seek_counter) << endl;
+                       if (sc != g_atomic_int_get (&_seek_counter)) {
+                               cerr << "\n\n RESTART locate, new seek delivered\n";
+                               goto restart;
+                       }
                }
+
+               cerr << "\n\n <<< DONE Non-RT locate on routes\n\n";
        }
+
        {
+               /* VCAs are quick to locate because they have no data (except
+                  automation) associated with them. Don't bother with a
+                  restart mechanism here, but do use the same transport frame
+                  that the Routes used.
+               */
                VCAList v = _vca_manager->vcas ();
                for (VCAList::const_iterator i = v.begin(); i != v.end(); ++i) {
-                       (*i)->non_realtime_locate (_transport_frame);
+                       (*i)->non_realtime_locate (tf);
                }
        }
 
+       microseconds_t end = get_microseconds ();
+       cerr << "Locate took " << setprecision (3) << ((end - begin) /1000000.0) << " secs\n";
+
        _scene_changer->locate (_transport_frame);
 
        /* XXX: it would be nice to generate the new clicks here (in the non-RT thread)
@@ -1024,7 +1042,7 @@ Session::set_track_loop (bool yn)
 
        for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
                boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
-               if (tr && !tr->hidden()) {
+               if (tr && !tr->is_private_route()) {
                        tr->set_loop (yn ? loc : 0);
                }
        }
@@ -1230,12 +1248,18 @@ Session::locate (framepos_t target_frame, bool with_roll, bool with_flush, bool
                        pending_locate_frame = target_frame;
                        pending_locate_roll = with_roll;
                        pending_locate_flush = with_flush;
+                       cerr << "Declick scheduled ... back soon\n";
                        return;
                }
        }
 
+       cerr << "... now doing the actual locate\n";
+
        // Update Timecode time
        _transport_frame = target_frame;
+       // Bump seek counter so that any in-process locate in the butler
+       // thread(s?) can restart.
+       g_atomic_int_inc (&_seek_counter);
        _last_roll_or_reversal_location = target_frame;
        timecode_time(_transport_frame, transmitting_timecode_time);
 
@@ -1820,6 +1844,12 @@ Session::use_sync_source (Slave* new_slave)
        delete _slave;
        _slave = new_slave;
 
+
+       /* slave change, reset any DiskIO block on disk output because it is no
+          longer valid with a new slave.
+       */
+       DiskReader::set_no_disk_output (false);
+
        MTC_Slave* mtc_slave = dynamic_cast<MTC_Slave*>(_slave);
        if (mtc_slave) {
                mtc_slave->ActiveChanged.connect_same_thread (mtc_status_connection, boost::bind (&Session::mtc_status_changed, this, _1));
@@ -1852,7 +1882,7 @@ Session::use_sync_source (Slave* new_slave)
        boost::shared_ptr<RouteList> rl = routes.reader();
        for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
                boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
-               if (tr && !tr->hidden()) {
+               if (tr && !tr->is_private_route()) {
                        if (tr->realtime_speed_change()) {
                                non_rt_required = true;
                        }