diff options
author | Carl Hetherington <carl@carlh.net> | 2010-07-03 00:11:33 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2010-07-03 00:11:33 +0000 |
commit | bde4d3f3412e16543faff7bd489beb040311b781 (patch) | |
tree | 2e743f306fec80520cd1bdec474f27c90aa57739 /libs | |
parent | 2062ce8186592801d84162f6fa14173769b37521 (diff) |
Fix up my previous buggy MMC cleanup.
git-svn-id: svn://localhost/ardour2/branches/3.0@7363 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r-- | libs/ardour/session.cc | 12 | ||||
-rw-r--r-- | libs/ardour/session_midi.cc | 20 | ||||
-rw-r--r-- | libs/ardour/session_process.cc | 4 | ||||
-rw-r--r-- | libs/ardour/session_state.cc | 40 | ||||
-rw-r--r-- | libs/ardour/session_transport.cc | 22 | ||||
-rw-r--r-- | libs/midi++2/midi++/mmc.h | 12 | ||||
-rw-r--r-- | libs/midi++2/mmc.cc | 26 |
7 files changed, 71 insertions, 65 deletions
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index ea48f9c60f..675cd9acfe 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -961,9 +961,7 @@ Session::enable_record () if (g_atomic_int_get (&_record_status) != Recording) { g_atomic_int_set (&_record_status, Recording); _last_record_location = _transport_frame; - if (_mmc) { - _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordStrobe)); - } + _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordStrobe)); if (Config->get_monitoring_model() == HardwareMonitoring && config.get_auto_input()) { @@ -989,9 +987,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); - if (_mmc) { - _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordExit)); - } + _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordExit)); } else { if (rs == Recording) { g_atomic_int_set (&_record_status, Enabled); @@ -1051,9 +1047,7 @@ Session::maybe_enable_record () enable_record (); } } else { - if (_mmc) { - _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordPause)); - } + _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordPause)); RecordStateChanged (); /* EMIT SIGNAL */ } diff --git a/libs/ardour/session_midi.cc b/libs/ardour/session_midi.cc index 425c12db6c..1f8f28cfc1 100644 --- a/libs/ardour/session_midi.cc +++ b/libs/ardour/session_midi.cc @@ -76,6 +76,10 @@ Session::use_config_midi_ports () { string port_name; + if (default_mmc_port) { + _mmc->set_port (default_mmc_port); + } + if (default_mtc_port) { set_mtc_port (default_mtc_port->name()); } else { @@ -230,26 +234,26 @@ Session::set_trace_midi_input (bool yn, MIDI::Port* port) } } else { - if (_mmc && _mmc->port()) { + if (_mmc->port()) { if ((input_parser = _mmc->port()->input()) != 0) { input_parser->trace (yn, &cout, "input: "); } } - if (_mtc_port && (!_mmc || (_mtc_port != _mmc->port()))) { + if (_mtc_port && _mtc_port != _mmc->port()) { if ((input_parser = _mtc_port->input()) != 0) { input_parser->trace (yn, &cout, "input: "); } } - if (_midi_port && (!_mmc || (_midi_port != _mmc->port())) && _midi_port != _mtc_port ) { + if (_midi_port && _midi_port != _mmc->port() && _midi_port != _mtc_port) { if ((input_parser = _midi_port->input()) != 0) { input_parser->trace (yn, &cout, "input: "); } } if (_midi_clock_port - && (!_mmc || (_midi_clock_port != _mmc->port())) + && _midi_clock_port != _mmc->port() && _midi_clock_port != _mtc_port && _midi_clock_port != _midi_port) { if ((input_parser = _midi_clock_port->input()) != 0) { @@ -271,7 +275,7 @@ Session::set_trace_midi_output (bool yn, MIDI::Port* port) output_parser->trace (yn, &cout, "output: "); } } else { - if (_mmc && _mmc->port()) { + if (_mmc->port()) { if ((output_parser = _mmc->port()->output()) != 0) { output_parser->trace (yn, &cout, "output: "); } @@ -283,7 +287,7 @@ Session::set_trace_midi_output (bool yn, MIDI::Port* port) } } - if (_midi_port && (!_mmc || (_midi_port != _mmc->port())) && _midi_port != _mtc_port ) { + if (_midi_port && _midi_port != _mmc->port() && _midi_port != _mtc_port) { if ((output_parser = _midi_port->output()) != 0) { output_parser->trace (yn, &cout, "output: "); } @@ -304,7 +308,7 @@ Session::get_trace_midi_input(MIDI::Port *port) } } else { - if (_mmc && _mmc->port()) { + if (_mmc->port()) { if ((input_parser = _mmc->port()->input()) != 0) { return input_parser->tracing(); } @@ -336,7 +340,7 @@ Session::get_trace_midi_output(MIDI::Port *port) } } else { - if (_mmc && _mmc->port()) { + if (_mmc->port()) { if ((output_parser = _mmc->port()->output()) != 0) { return output_parser->tracing(); } diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc index 5c67b6b299..e555350088 100644 --- a/libs/ardour/session_process.cc +++ b/libs/ardour/session_process.cc @@ -69,9 +69,7 @@ Session::process (nframes_t nframes) } } - if (_mmc) { - _mmc->flush_pending (); - } + _mmc->flush_pending (); _engine.main_thread()->get_buffers (); diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 86bc6a112b..e91e4bddd4 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -353,10 +353,8 @@ Session::second_stage_init () send_full_time_code (0); _engine.transport_locate (0); - if (_mmc) { - _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdMmcReset)); - _mmc->send (MIDI::MachineControlCommand (Timecode::Time ())); - } + _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdMmcReset)); + _mmc->send (MIDI::MachineControlCommand (Timecode::Time ())); MidiClockTicker::instance().set_session (this); MIDI::Name::MidiPatchManager::instance().set_session (this); @@ -1245,10 +1243,7 @@ Session::set_state (const XMLNode& node, int version) error << _("Session: XML state has no options section") << endmsg; } - setup_midi_machine_control (); - - if (use_config_midi_ports ()) { - } + use_config_midi_ports (); if (version >= 3000) { if ((child = find_named_node (node, "Metadata")) == 0) { @@ -3194,15 +3189,11 @@ Session::config_changed (std::string p, bool ours) } else if (p == "mmc-device-id" || p == "mmc-receive-id") { - if (_mmc) { - _mmc->set_receive_device_id (Config->get_mmc_receive_device_id()); - } + _mmc->set_receive_device_id (Config->get_mmc_receive_device_id()); } else if (p == "mmc-send-id") { - if (_mmc) { - _mmc->set_send_device_id (Config->get_mmc_send_device_id()); - } + _mmc->set_send_device_id (Config->get_mmc_send_device_id()); } else if (p == "midi-control") { @@ -3268,9 +3259,7 @@ Session::config_changed (std::string p, bool ours) } else if (p == "send-mmc") { - if (_mmc) { - _mmc->enable_send (Config->get_send_mmc ()); - } + _mmc->enable_send (Config->get_send_mmc ()); } else if (p == "midi-feedback") { @@ -3318,7 +3307,7 @@ Session::config_changed (std::string p, bool ours) sync_order_keys ("session"); } else if (p == "initial-program-change") { - if (_mmc && _mmc->port() && Config->get_initial_program_change() >= 0) { + if (_mmc->port() && Config->get_initial_program_change() >= 0) { MIDI::byte buf[2]; buf[0] = MIDI::program; // channel zero by default @@ -3328,7 +3317,7 @@ Session::config_changed (std::string p, bool ours) } } else if (p == "initial-program-change") { - if (_mmc && _mmc->port() && Config->get_initial_program_change() >= 0) { + if (_mmc->port() && Config->get_initial_program_change() >= 0) { MIDI::byte* buf = new MIDI::byte[2]; buf[0] = MIDI::program; // channel zero by default @@ -3386,13 +3375,8 @@ Session::load_diskstreams_2X (XMLNode const & node, int) void Session::setup_midi_machine_control () { - if (!default_mmc_port) { - return; - } - _mmc = new MIDI::MachineControl; - _mmc->set_port (default_mmc_port); - + _mmc->Play.connect_same_thread (*this, boost::bind (&Session::mmc_deferred_play, this, _1)); _mmc->DeferredPlay.connect_same_thread (*this, boost::bind (&Session::mmc_deferred_play, this, _1)); _mmc->Stop.connect_same_thread (*this, boost::bind (&Session::mmc_stop, this, _1)); @@ -3409,7 +3393,7 @@ Session::setup_midi_machine_control () /* also handle MIDI SPP because its so common */ - _mmc->port()->input()->start.connect_same_thread (*this, boost::bind (&Session::spp_start, this, _1, _2)); - _mmc->port()->input()->contineu.connect_same_thread (*this, boost::bind (&Session::spp_continue, this, _1, _2)); - _mmc->port()->input()->stop.connect_same_thread (*this, boost::bind (&Session::spp_stop, this, _1, _2)); + _mmc->SPPStart.connect_same_thread (*this, boost::bind (&Session::spp_start, this, _1, _2)); + _mmc->SPPContinue.connect_same_thread (*this, boost::bind (&Session::spp_continue, this, _1, _2)); + _mmc->SPPStop.connect_same_thread (*this, boost::bind (&Session::spp_stop, this, _1, _2)); } diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc index bccc97e271..7b04b58974 100644 --- a/libs/ardour/session_transport.cc +++ b/libs/ardour/session_transport.cc @@ -183,13 +183,11 @@ Session::realtime_stop (bool abort, bool clear_state) // FIXME: where should this really be? [DR] //send_full_time_code(); - if (_mmc) { - Timecode::Time time; - timecode_time_subframes (_transport_frame, time); - - _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdStop)); - _mmc->send (MIDI::MachineControlCommand (time)); - } + Timecode::Time time; + timecode_time_subframes (_transport_frame, time); + + _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdStop)); + _mmc->send (MIDI::MachineControlCommand (time)); if (_transport_speed < 0.0f) { todo = (PostTransportWork (todo | PostTransportStop | PostTransportReverse)); @@ -896,7 +894,7 @@ Session::locate (nframes64_t target_frame, bool with_roll, bool with_flush, bool _send_timecode_update = true; - if (with_mmc && _mmc) { + if (with_mmc) { Timecode::Time time; timecode_time_subframes (_transport_frame, time); _mmc->send (MIDI::MachineControlCommand (time)); @@ -1136,11 +1134,9 @@ Session::start_transport () } } - if (_mmc) { - Timecode::Time time; - timecode_time_subframes (_transport_frame, time); - _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdDeferredPlay)); - } + Timecode::Time time; + timecode_time_subframes (_transport_frame, time); + _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdDeferredPlay)); TransportStateChange (); /* EMIT SIGNAL */ } diff --git a/libs/midi++2/midi++/mmc.h b/libs/midi++2/midi++/mmc.h index 2dc38e81c0..61415d39f2 100644 --- a/libs/midi++2/midi++/mmc.h +++ b/libs/midi++2/midi++/mmc.h @@ -24,12 +24,13 @@ #include "pbd/signals.h" #include "pbd/ringbuffer.h" #include "midi++/types.h" +#include "midi++/parser.h" namespace MIDI { class Port; class Parser; -class MachineControlCommand; +class MachineControlCommand; /** Class to handle incoming and outgoing MIDI machine control messages */ class MachineControl @@ -143,6 +144,10 @@ class MachineControl MMCSignal Wait; MMCSignal Resume; + TimestampedSignal SPPStart; + TimestampedSignal SPPContinue; + TimestampedSignal SPPStop; + /* The second argument is the shuttle speed, the third is true if the direction is "forwards", false for "reverse" */ @@ -264,7 +269,7 @@ class MachineControl static pthread_t _sending_thread; void process_mmc_message (Parser &p, byte *, size_t len); - PBD::ScopedConnection mmc_connection; ///< connection to our parser for incoming data + PBD::ScopedConnectionList port_connections; ///< connections to our parser for incoming data int do_masked_write (byte *, size_t len); int do_locate (byte *, size_t len); @@ -273,6 +278,9 @@ class MachineControl void send_immediately (MachineControlCommand const &); void write_track_status (byte *, size_t len, byte reg); + void spp_start (Parser&, nframes_t); + void spp_continue (Parser&, nframes_t); + void spp_stop (Parser&, nframes_t); }; /** Class to describe a MIDI machine control command to be sent. diff --git a/libs/midi++2/mmc.cc b/libs/midi++2/mmc.cc index 8adfcafb85..79132f0e1a 100644 --- a/libs/midi++2/mmc.cc +++ b/libs/midi++2/mmc.cc @@ -210,10 +210,13 @@ MachineControl::set_port (Port* p) { _port = p; - mmc_connection.disconnect (); + port_connections.drop_connections (); if (_port->input()) { - _port->input()->mmc.connect_same_thread (mmc_connection, boost::bind (&MachineControl::process_mmc_message, this, _1, _2, _3)); + _port->input()->mmc.connect_same_thread (port_connections, boost::bind (&MachineControl::process_mmc_message, this, _1, _2, _3)); + _port->input()->start.connect_same_thread (port_connections, boost::bind (&MachineControl::spp_start, this, _1, _2)); + _port->input()->contineu.connect_same_thread (port_connections, boost::bind (&MachineControl::spp_continue, this, _1, _2)); + _port->input()->stop.connect_same_thread (port_connections, boost::bind (&MachineControl::spp_stop, this, _1, _2)); } else { warning << "MMC connected to a non-input port: useless!" << endmsg; } @@ -688,6 +691,24 @@ MachineControl::set_sending_thread (pthread_t t) _sending_thread = t; } +void +MachineControl::spp_start (Parser& parser, nframes_t timestamp) +{ + SPPStart (parser, timestamp); /* EMIT SIGNAL */ +} + +void +MachineControl::spp_continue (Parser& parser, nframes_t timestamp) +{ + SPPContinue (parser, timestamp); /* EMIT SIGNAL */ +} + +void +MachineControl::spp_stop (Parser& parser, nframes_t timestamp) +{ + SPPStop (parser, timestamp); /* EMIT SIGNAL */ +} + MachineControlCommand::MachineControlCommand (MachineControl::Command c) : _command (c) { @@ -725,3 +746,4 @@ MachineControlCommand::fill_buffer (MachineControl* mmc, MIDI::byte* b) const return b; } + |