diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2015-12-07 12:02:42 -0500 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2015-12-07 12:38:17 -0500 |
commit | 41b2de41d69c2ecc381867e502e4760267275425 (patch) | |
tree | d19b1310b19b238139ca2aab6e2592f3256a9597 /libs/ardour/session_state.cc | |
parent | 4bb5278b623dfb2c537d5eec0c3597f7d30eb5e0 (diff) |
change API for accessing session MIDI ports so that (1) boost::shared_ptr<> is used all the time (2) we avoid using multiple functions to return different subclass versions of some ports
Diffstat (limited to 'libs/ardour/session_state.cc')
-rw-r--r-- | libs/ardour/session_state.cc | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 48bacdfe07..c440b77895 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -217,11 +217,11 @@ Session::post_engine_init () MIDISceneChanger* msc; _scene_changer = msc = new MIDISceneChanger (*this); - msc->set_input_port (scene_input_port()); - msc->set_output_port (scene_out()); + msc->set_input_port (boost::dynamic_pointer_cast<MidiPort>(scene_input_port())); + msc->set_output_port (boost::dynamic_pointer_cast<MidiPort>(scene_output_port())); boost::function<framecnt_t(void)> timer_func (boost::bind (&Session::audible_frame, this)); - boost::dynamic_pointer_cast<AsyncMIDIPort>(scene_in())->set_timer (timer_func); + boost::dynamic_pointer_cast<AsyncMIDIPort>(scene_input_port())->set_timer (timer_func); setup_midi_machine_control (); @@ -3875,7 +3875,20 @@ void Session::setup_midi_machine_control () { _mmc = new MIDI::MachineControl; - _mmc->set_ports (_midi_ports->mmc_input_port(), _midi_ports->mmc_output_port()); + + boost::shared_ptr<AsyncMIDIPort> async_in = boost::dynamic_pointer_cast<AsyncMIDIPort> (_midi_ports->mmc_input_port()); + boost::shared_ptr<AsyncMIDIPort> async_out = boost::dynamic_pointer_cast<AsyncMIDIPort> (_midi_ports->mmc_output_port()); + + if (!async_out || !async_out) { + return; + } + + /* XXXX argh, passing raw pointers back into libmidi++ */ + + MIDI::Port* mmc_in = async_in.get(); + MIDI::Port* mmc_out = async_out.get(); + + _mmc->set_ports (mmc_in, mmc_out); _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)); |