diff --git a/gtk2_ardour/midi_tracer.cc b/gtk2_ardour/midi_tracer.cc index b64daa5c04..fdc4e5b8d9 100644 --- a/gtk2_ardour/midi_tracer.cc +++ b/gtk2_ardour/midi_tracer.cc @@ -172,16 +172,29 @@ MidiTracer::port_changed () * 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 async = boost::dynamic_pointer_cast (p); if (!async) { boost::shared_ptr mp = boost::dynamic_pointer_cast (p); - if (mp) { - 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; + if (mp->flags() & TransportMasterPort) { + boost::shared_ptr tm = TransportMasterManager::instance().master_by_port(boost::dynamic_pointer_cast (p)); + boost::shared_ptr tm_midi = boost::dynamic_pointer_cast (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 {