fix minor problem with recent cherry-picking from cairocanvas
[ardour.git] / libs / ardour / session_transport.cc
index 44a885cd1c93090a23d8ac2cef60c4af3fbc94e6..38ad5212359a7377e2e5cf045a11197b83fdc6ab 100644 (file)
@@ -86,7 +86,7 @@ Session::request_sync_source (Slave* new_slave)
 
        seamless = Config->get_seamless_loop ();
 
-       if (dynamic_cast<JACK_Slave*>(new_slave)) {
+       if (dynamic_cast<Engine_Slave*>(new_slave)) {
                /* JACK cannot support seamless looping at present */
                Config->set_seamless_loop (false);
        } else {
@@ -514,13 +514,13 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished)
        if (auto_return_enabled ||
            (ptw & PostTransportLocate) ||
            (_requested_return_frame >= 0) ||
-           synced_to_jack()) {
+           synced_to_engine()) {
 
                if (pending_locate_flush) {
                        flush_all_inserts ();
                }
 
-               if ((auto_return_enabled || synced_to_jack() || _requested_return_frame >= 0) &&
+               if ((auto_return_enabled || synced_to_engine() || _requested_return_frame >= 0) &&
                    !(ptw & PostTransportLocate)) {
 
                        /* no explicit locate queued */
@@ -543,7 +543,7 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished)
 
                                                /* don't try to handle loop play when synced to JACK */
 
-                                               if (!synced_to_jack()) {
+                                               if (!synced_to_engine()) {
 
                                                        Location *location = _locations->auto_loop_location();
 
@@ -609,12 +609,23 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished)
 
        have_looped = false;
 
-       if (!_engine.freewheeling()) {
+       /* don't bother with this stuff if we're disconnected from the engine,
+          because there will be no process callbacks to deliver stuff from
+       */
+
+       if (_engine.connected() && !_engine.freewheeling()) {
                // need to queue this in the next RT cycle
                _send_timecode_update = true;
                
                if (!dynamic_cast<MTC_Slave*>(_slave)) {
-                       AudioEngine::instance()->mmc().send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdStop));
+                       _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdStop));
+
+                       /* This (::non_realtime_stop()) gets called by main
+                          process thread, which will lead to confusion
+                          when calling AsyncMIDIPort::write().
+                          
+                          Something must be done. XXX
+                       */
                        send_mmc_locate (_transport_frame);
                }
        }
@@ -723,7 +734,7 @@ Session::set_play_loop (bool yn)
                return;
        }
 
-       if (yn && Config->get_seamless_loop() && synced_to_jack()) {
+       if (yn && Config->get_seamless_loop() && synced_to_engine()) {
                warning << string_compose (
                        _("Seamless looping cannot be supported while %1 is using JACK transport.\n"
                          "Recommend changing the configured options"), PROGRAM_NAME)
@@ -800,7 +811,7 @@ Session::flush_all_inserts ()
 void
 Session::start_locate (framepos_t target_frame, bool with_roll, bool with_flush, bool with_loop, bool force)
 {
-       if (synced_to_jack()) {
+       if (synced_to_engine()) {
 
                double sp;
                framepos_t pos;
@@ -915,7 +926,7 @@ Session::locate (framepos_t target_frame, bool with_roll, bool with_flush, bool
 
        bool transport_was_stopped = !transport_rolling();
 
-       if (transport_was_stopped && (!auto_play_legal || !config.get_auto_play()) && !with_roll && !(synced_to_jack() && play_loop)) {
+       if (transport_was_stopped && (!auto_play_legal || !config.get_auto_play()) && !with_roll && !(synced_to_engine() && play_loop)) {
                realtime_stop (false, true); // XXX paul - check if the 2nd arg is really correct
                transport_was_stopped = true;
        } else {
@@ -1056,7 +1067,7 @@ Session::set_transport_speed (double speed, bool abort, bool clear_state, bool a
                        set_track_monitor_input_status (true);
                }
 
-               if (synced_to_jack ()) {
+               if (synced_to_engine ()) {
                        if (clear_state) {
                                /* do this here because our response to the slave won't
                                   take care of it.
@@ -1079,7 +1090,7 @@ Session::set_transport_speed (double speed, bool abort, bool clear_state, bool a
                        set_track_monitor_input_status (false);
                }
 
-               if (synced_to_jack()) {
+               if (synced_to_engine()) {
                        _engine.transport_start ();
                } else {
                        start_transport ();
@@ -1089,7 +1100,7 @@ Session::set_transport_speed (double speed, bool abort, bool clear_state, bool a
 
                /* not zero, not 1.0 ... varispeed */
 
-               if ((synced_to_jack()) && speed != 0.0 && speed != 1.0) {
+               if ((synced_to_engine()) && speed != 0.0 && speed != 1.0) {
                        warning << string_compose (
                                _("Global varispeed cannot be supported while %1 is connected to JACK transport control"),
                                PROGRAM_NAME)
@@ -1260,7 +1271,7 @@ Session::start_transport ()
                Timecode::Time time;
                timecode_time_subframes (_transport_frame, time);
                if (!dynamic_cast<MTC_Slave*>(_slave)) {
-                       AudioEngine::instance()->mmc().send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdDeferredPlay));
+                       _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdDeferredPlay));
                }
        }
 
@@ -1381,7 +1392,7 @@ Session::switch_to_sync_source (SyncSource src)
                }
 
                try {
-                       new_slave = new MTC_Slave (*this, *AudioEngine::instance()->mtc_input_port());
+                       new_slave = new MTC_Slave (*this, *_midi_ports->mtc_input_port());
                }
 
                catch (failed_constructor& err) {
@@ -1410,7 +1421,7 @@ Session::switch_to_sync_source (SyncSource src)
                }
 
                try {
-                       new_slave = new MIDIClock_Slave (*this, *AudioEngine::instance()->midi_clock_input_port(), 24);
+                       new_slave = new MIDIClock_Slave (*this, *_midi_ports->midi_clock_input_port(), 24);
                }
 
                catch (failed_constructor& err) {
@@ -1418,8 +1429,8 @@ Session::switch_to_sync_source (SyncSource src)
                }
                break;
 
-       case JACK:
-               if (_slave && dynamic_cast<JACK_Slave*>(_slave)) {
+       case Engine:
+               if (_slave && dynamic_cast<Engine_Slave*>(_slave)) {
                        return;
                }
 
@@ -1427,7 +1438,7 @@ Session::switch_to_sync_source (SyncSource src)
                        return;
                }
 
-               new_slave = new JACK_Slave (*AudioEngine::instance());
+               new_slave = new Engine_Slave (*AudioEngine::instance());
                break;
 
        default:
@@ -1621,9 +1632,9 @@ bool
 Session::maybe_stop (framepos_t limit)
 {
        if ((_transport_speed > 0.0f && _transport_frame >= limit) || (_transport_speed < 0.0f && _transport_frame == 0)) {
-               if (synced_to_jack () && config.get_jack_time_master ()) {
+               if (synced_to_engine () && config.get_jack_time_master ()) {
                        _engine.transport_stop ();
-               } else if (!synced_to_jack ()) {
+               } else if (!synced_to_engine ()) {
                        stop_transport ();
                }
                return true;
@@ -1637,7 +1648,7 @@ Session::send_mmc_locate (framepos_t t)
        if (!_engine.freewheeling()) {
                Timecode::Time time;
                timecode_time_subframes (t, time);
-               AudioEngine::instance()->mmc().send (MIDI::MachineControlCommand (time));
+               _mmc->send (MIDI::MachineControlCommand (time));
        }
 }