Fix Midi Tracer handling of different port types

Transport Masters and Async MIDI port already have a parser available, so
just connect to it.

Normal Midi ports are the only one that need to use the Midi Tracers parser.
This commit is contained in:
Todd Naugle 2021-06-22 22:21:37 -05:00
parent 89eab2714f
commit 6f251f8b2f

View file

@ -172,16 +172,29 @@ MidiTracer::port_changed ()
* this mess will all go away ... * this mess will all go away ...
*/ */
/* Some ports have a parser avaiable (Transport Masters and ASYNC ports)
* and some do not. If the port has a parser already, just attach to it.
* If not use our local parser and tell the port that we need it to be called.
*/
boost::shared_ptr<AsyncMIDIPort> async = boost::dynamic_pointer_cast<AsyncMIDIPort> (p); boost::shared_ptr<AsyncMIDIPort> async = boost::dynamic_pointer_cast<AsyncMIDIPort> (p);
if (!async) { if (!async) {
boost::shared_ptr<ARDOUR::MidiPort> mp = boost::dynamic_pointer_cast<ARDOUR::MidiPort> (p); boost::shared_ptr<ARDOUR::MidiPort> mp = boost::dynamic_pointer_cast<ARDOUR::MidiPort> (p);
if (mp) { if (mp) {
my_parser.any.connect_same_thread (_parser_connection, boost::bind (&MidiTracer::tracer, this, _1, _2, _3, _4)); if (mp->flags() & TransportMasterPort) {
mp->set_trace (&my_parser); boost::shared_ptr<TransportMaster> tm = TransportMasterManager::instance().master_by_port(boost::dynamic_pointer_cast<ARDOUR::Port> (p));
traced_port = mp; boost::shared_ptr<TransportMasterViaMIDI> tm_midi = boost::dynamic_pointer_cast<TransportMasterViaMIDI> (tm);
if (tm_midi) {
tm_midi->transport_parser().any.connect_same_thread(_parser_connection, boost::bind (&MidiTracer::tracer, this, _1, _2, _3, _4));
}
}
else {
my_parser.any.connect_same_thread (_parser_connection, boost::bind (&MidiTracer::tracer, this, _1, _2, _3, _4));
mp->set_trace (&my_parser);
traced_port = mp;
}
} }
} else { } else {