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/midi_scene_changer.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/midi_scene_changer.cc')
-rw-r--r-- | libs/ardour/midi_scene_changer.cc | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/libs/ardour/midi_scene_changer.cc b/libs/ardour/midi_scene_changer.cc index f586206ba7..7f6c865922 100644 --- a/libs/ardour/midi_scene_changer.cc +++ b/libs/ardour/midi_scene_changer.cc @@ -226,13 +226,16 @@ MIDISceneChanger::locate (framepos_t pos) } void -MIDISceneChanger::set_input_port (MIDI::Port* mp) +MIDISceneChanger::set_input_port (boost::shared_ptr<MidiPort> mp) { - input_port = mp; - incoming_connections.drop_connections(); + input_port.reset (); + + boost::shared_ptr<AsyncMIDIPort> async = boost::dynamic_pointer_cast<AsyncMIDIPort> (mp); + + if (async) { - if (input_port) { + input_port = mp; /* midi port is asynchronous. MIDI parsing will be carried out * by the MIDI UI thread which will emit the relevant signals @@ -240,8 +243,8 @@ MIDISceneChanger::set_input_port (MIDI::Port* mp) */ for (int channel = 0; channel < 16; ++channel) { - input_port->parser()->channel_bank_change[channel].connect_same_thread (incoming_connections, boost::bind (&MIDISceneChanger::bank_change_input, this, _1, _2, channel)); - input_port->parser()->channel_program_change[channel].connect_same_thread (incoming_connections, boost::bind (&MIDISceneChanger::program_change_input, this, _1, _2, channel)); + async->parser()->channel_bank_change[channel].connect_same_thread (incoming_connections, boost::bind (&MIDISceneChanger::bank_change_input, this, _1, _2, channel)); + async->parser()->channel_program_change[channel].connect_same_thread (incoming_connections, boost::bind (&MIDISceneChanger::program_change_input, this, _1, _2, channel)); } } } @@ -286,7 +289,7 @@ MIDISceneChanger::program_change_input (MIDI::Parser& parser, MIDI::byte program int bank = -1; if (have_seen_bank_changes) { - bank = input_port->channel (channel)->bank(); + bank = boost::dynamic_pointer_cast<AsyncMIDIPort>(input_port)->channel (channel)->bank(); } jump_to (bank, program); @@ -317,7 +320,7 @@ MIDISceneChanger::program_change_input (MIDI::Parser& parser, MIDI::byte program int bank = -1; if (have_seen_bank_changes) { - bank = input_port->channel (channel)->bank(); + bank = boost::dynamic_pointer_cast<AsyncMIDIPort>(input_port)->channel (channel)->bank(); } MIDISceneChange* msc =new MIDISceneChange (channel, bank, program & 0x7f); |