From 4916df760cf1a4db919467cc7c6a978d54cbeef3 Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 1 Jul 2010 15:03:49 +0000 Subject: [PATCH] fix assumption that Session::_mmc != 0 git-svn-id: http://subversion.ardour.org/svn/ardour2/ardour2/branches/3.0@7349 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/session_midi.cc | 16 ++++++++-------- libs/ardour/session_process.cc | 4 +++- libs/ardour/session_state.cc | 29 +++++++++++++++++++++-------- libs/ardour/session_transport.cc | 21 +++++++++++++-------- libs/ardour/smf_source.cc | 1 - 5 files changed, 45 insertions(+), 26 deletions(-) diff --git a/libs/ardour/session_midi.cc b/libs/ardour/session_midi.cc index 201c91358..425c12db6 100644 --- a/libs/ardour/session_midi.cc +++ b/libs/ardour/session_midi.cc @@ -230,26 +230,26 @@ Session::set_trace_midi_input (bool yn, MIDI::Port* port) } } else { - if (_mmc->port()) { + if (_mmc && _mmc->port()) { if ((input_parser = _mmc->port()->input()) != 0) { input_parser->trace (yn, &cout, "input: "); } } - if (_mtc_port && _mtc_port != _mmc->port()) { + if (_mtc_port && (!_mmc || (_mtc_port != _mmc->port()))) { if ((input_parser = _mtc_port->input()) != 0) { input_parser->trace (yn, &cout, "input: "); } } - if (_midi_port && _midi_port != _mmc->port() && _midi_port != _mtc_port ) { + if (_midi_port && (!_mmc || (_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 - && _midi_clock_port != _mmc->port() + && (!_mmc || (_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 +271,7 @@ Session::set_trace_midi_output (bool yn, MIDI::Port* port) output_parser->trace (yn, &cout, "output: "); } } else { - if (_mmc->port()) { + if (_mmc && _mmc->port()) { if ((output_parser = _mmc->port()->output()) != 0) { output_parser->trace (yn, &cout, "output: "); } @@ -283,7 +283,7 @@ Session::set_trace_midi_output (bool yn, MIDI::Port* port) } } - if (_midi_port && _midi_port != _mmc->port() && _midi_port != _mtc_port ) { + if (_midi_port && (!_mmc || (_midi_port != _mmc->port())) && _midi_port != _mtc_port ) { if ((output_parser = _midi_port->output()) != 0) { output_parser->trace (yn, &cout, "output: "); } @@ -304,7 +304,7 @@ Session::get_trace_midi_input(MIDI::Port *port) } } else { - if (_mmc->port()) { + if (_mmc && _mmc->port()) { if ((input_parser = _mmc->port()->input()) != 0) { return input_parser->tracing(); } @@ -336,7 +336,7 @@ Session::get_trace_midi_output(MIDI::Port *port) } } else { - if (_mmc->port()) { + if (_mmc && _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 e55535008..5c67b6b29 100644 --- a/libs/ardour/session_process.cc +++ b/libs/ardour/session_process.cc @@ -69,7 +69,9 @@ Session::process (nframes_t nframes) } } - _mmc->flush_pending (); + if (_mmc) { + _mmc->flush_pending (); + } _engine.main_thread()->get_buffers (); diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 99a8ae2e9..86bc6a112 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -352,8 +352,11 @@ Session::second_stage_init () send_full_time_code (0); _engine.transport_locate (0); - _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdMmcReset)); - _mmc->send (MIDI::MachineControlCommand (Timecode::Time ())); + + if (_mmc) { + _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); @@ -3191,11 +3194,15 @@ Session::config_changed (std::string p, bool ours) } else if (p == "mmc-device-id" || p == "mmc-receive-id") { - _mmc->set_receive_device_id (Config->get_mmc_receive_device_id()); + if (_mmc) { + _mmc->set_receive_device_id (Config->get_mmc_receive_device_id()); + } } else if (p == "mmc-send-id") { - _mmc->set_send_device_id (Config->get_mmc_send_device_id()); + if (_mmc) { + _mmc->set_send_device_id (Config->get_mmc_send_device_id()); + } } else if (p == "midi-control") { @@ -3261,7 +3268,9 @@ Session::config_changed (std::string p, bool ours) } else if (p == "send-mmc") { - _mmc->enable_send (Config->get_send_mmc ()); + if (_mmc) { + _mmc->enable_send (Config->get_send_mmc ()); + } } else if (p == "midi-feedback") { @@ -3309,7 +3318,7 @@ Session::config_changed (std::string p, bool ours) sync_order_keys ("session"); } else if (p == "initial-program-change") { - if (_mmc->port() && Config->get_initial_program_change() >= 0) { + if (_mmc && _mmc->port() && Config->get_initial_program_change() >= 0) { MIDI::byte buf[2]; buf[0] = MIDI::program; // channel zero by default @@ -3318,8 +3327,8 @@ Session::config_changed (std::string p, bool ours) _mmc->port()->midimsg (buf, sizeof (buf), 0); } } else if (p == "initial-program-change") { - - if (_mmc->port() && Config->get_initial_program_change() >= 0) { + + if (_mmc && _mmc->port() && Config->get_initial_program_change() >= 0) { MIDI::byte* buf = new MIDI::byte[2]; buf[0] = MIDI::program; // channel zero by default @@ -3377,6 +3386,10 @@ 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); diff --git a/libs/ardour/session_transport.cc b/libs/ardour/session_transport.cc index 74eafa0f1..bccc97e27 100644 --- a/libs/ardour/session_transport.cc +++ b/libs/ardour/session_transport.cc @@ -183,10 +183,13 @@ Session::realtime_stop (bool abort, bool clear_state) // FIXME: where should this really be? [DR] //send_full_time_code(); - _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdStop)); - Timecode::Time time; - timecode_time_subframes (_transport_frame, time); - _mmc->send (MIDI::MachineControlCommand (time)); + if (_mmc) { + 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)); @@ -893,7 +896,7 @@ Session::locate (nframes64_t target_frame, bool with_roll, bool with_flush, bool _send_timecode_update = true; - if (with_mmc) { + if (with_mmc && _mmc) { Timecode::Time time; timecode_time_subframes (_transport_frame, time); _mmc->send (MIDI::MachineControlCommand (time)); @@ -1133,9 +1136,11 @@ Session::start_transport () } } - Timecode::Time time; - timecode_time_subframes (_transport_frame, time); - _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdDeferredPlay)); + if (_mmc) { + Timecode::Time time; + timecode_time_subframes (_transport_frame, time); + _mmc->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdDeferredPlay)); + } TransportStateChange (); /* EMIT SIGNAL */ } diff --git a/libs/ardour/smf_source.cc b/libs/ardour/smf_source.cc index 5fef5f74a..0df128c14 100644 --- a/libs/ardour/smf_source.cc +++ b/libs/ardour/smf_source.cc @@ -384,7 +384,6 @@ SMFSource::mark_streaming_write_completed () MidiSource::mark_streaming_write_completed(); if (!writable()) { - cerr << "\n\n\n[[[[[[[[[ This SMFS is not writable! ]]]]]]]]]]]\n\n\n"; return; } -- 2.11.4.GIT