}
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
*/
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));
}
}
}
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);
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);