diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2014-10-22 17:06:53 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2014-10-22 17:07:11 -0400 |
commit | 679356c5ee1ac86ac6efa026e7ecfa514fa900d2 (patch) | |
tree | b9355fde50fb2567d3d7120a2d7c0086e79c1a02 | |
parent | e32a8e82602cc37476905187a0f30733127e5580 (diff) |
fix delivery of MMC events under split process cycle conditions
-rw-r--r-- | libs/ardour/ardour/session.h | 2 | ||||
-rw-r--r-- | libs/ardour/session.cc | 6 | ||||
-rw-r--r-- | libs/ardour/session_midi.cc | 13 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 4 | ||||
-rw-r--r-- | libs/ardour/session_transport.cc | 6 |
5 files changed, 22 insertions, 9 deletions
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 8621b64578..2c0ac05bda 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -48,6 +48,7 @@ #include "evoral/types.hpp" #include "midi++/types.h" +#include "midi++/mmc.h" #include "timecode/time.h" @@ -1248,6 +1249,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop MidiTimeoutList midi_timeouts; bool mmc_step_timeout (); + void send_immediate_mmc (MIDI::MachineControlCommand); MIDI::byte mtc_msg[16]; MIDI::byte mtc_timecode_bits; /* encoding of SMTPE type for MTC */ diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index b0d7a1ce4e..5575f42360 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -1380,7 +1380,7 @@ Session::enable_record () if (g_atomic_int_compare_and_exchange (&_record_status, rs, Recording)) { _last_record_location = _transport_frame; - _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordStrobe)); + send_immediate_mmc (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordStrobe)); if (Config->get_monitoring_model() == HardwareMonitoring && config.get_auto_input()) { set_track_monitor_input_status (true); @@ -1401,7 +1401,7 @@ Session::disable_record (bool rt_context, bool force) if ((!Config->get_latched_record_enable () && !play_loop) || force) { g_atomic_int_set (&_record_status, Disabled); - _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordExit)); + send_immediate_mmc (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordExit)); } else { if (rs == Recording) { g_atomic_int_set (&_record_status, Enabled); @@ -1455,7 +1455,7 @@ Session::maybe_enable_record () enable_record (); } } else { - _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordPause)); + send_immediate_mmc (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordPause)); RecordStateChanged (); /* EMIT SIGNAL */ } diff --git a/libs/ardour/session_midi.cc b/libs/ardour/session_midi.cc index 47c7bd4c40..7becd9c667 100644 --- a/libs/ardour/session_midi.cc +++ b/libs/ardour/session_midi.cc @@ -33,6 +33,7 @@ #include "pbd/error.h" #include "pbd/pthread_utils.h" #include "pbd/timersub.h" +#include "pbd/stacktrace.h" #include "timecode/time.h" @@ -425,7 +426,7 @@ Session::send_full_time_code (framepos_t const t, MIDI::pframes_t nframes) // Send message at offset 0, sent time is for the start of this cycle MidiBuffer& mb (_midi_ports->mtc_output_port()->get_midi_buffer (nframes)); - mb.push_back (0, sizeof (msg), msg); + mb.push_back (Port::port_offset(), sizeof (msg), msg); _pframes_since_last_mtc = 0; return 0; @@ -551,6 +552,16 @@ Session::send_midi_time_code_for_cycle (framepos_t start_frame, framepos_t end_f OUTBOUND MMC STUFF **********************************************************************/ +void +Session::send_immediate_mmc (MachineControlCommand c) +{ + if (AudioEngine::instance()->in_process_thread()) { + _mmc->send (c, Port::port_offset()); + } else { + _mmc->send (c, 0); + } + +} bool Session::mmc_step_timeout () diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 538c408abb..6560c6004b 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -334,8 +334,8 @@ Session::post_engine_init () // send_full_time_code (0); _engine.transport_locate (0); - _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdMmcReset)); - _mmc->send (MIDI::MachineControlCommand (Timecode::Time ())); + send_immediate_mmc (MIDI::MachineControlCommand (MIDI::MachineControl::cmdMmcReset)); + send_immediate_mmc (MIDI::MachineControlCommand (Timecode::Time ())); MIDI::Name::MidiPatchManager::instance().set_session (this); diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc index 6954bd0288..dec3683c19 100644 --- a/libs/ardour/session_transport.cc +++ b/libs/ardour/session_transport.cc @@ -656,7 +656,7 @@ Session::non_realtime_stop (bool abort, int on_entry, bool& finished) _send_timecode_update = true; if (!dynamic_cast<MTC_Slave*>(_slave)) { - _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdStop)); + send_immediate_mmc (MIDI::MachineControlCommand (MIDI::MachineControl::cmdStop)); /* This (::non_realtime_stop()) gets called by main process thread, which will lead to confusion @@ -1371,7 +1371,7 @@ Session::start_transport () Timecode::Time time; timecode_time_subframes (_transport_frame, time); if (!dynamic_cast<MTC_Slave*>(_slave)) { - _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdDeferredPlay)); + send_immediate_mmc (MIDI::MachineControlCommand (MIDI::MachineControl::cmdDeferredPlay)); } } @@ -1759,7 +1759,7 @@ Session::send_mmc_locate (framepos_t t) if (!_engine.freewheeling()) { Timecode::Time time; timecode_time_subframes (t, time); - _mmc->send (MIDI::MachineControlCommand (time)); + send_immediate_mmc (MIDI::MachineControlCommand (time)); } } |