13
0

Auto-connect MIDI track/bus when output ports change

previously this subscription was handle done in
Route::add_routes() -> add_routes_inner() for MIDI tracks only.

Since f6c0b02d9f this was only done when adding
tracks, after any instruments were loaded (and fanned out).
This commit is contained in:
Robin Gareus 2020-07-19 01:07:57 +02:00
parent f5727e50d1
commit c778ded411
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
2 changed files with 14 additions and 1 deletions

View File

@ -2556,6 +2556,10 @@ Session::midi_output_change_handler (IOChange change, void * /*src*/, boost::wea
{
boost::shared_ptr<Route> midi_route (wr.lock());
if (!midi_route) {
return;
}
if ((change.type & IOChange::ConfigurationChanged) && Config->get_output_auto_connect() != ManualConnect) {
if (change.after.n_audio() <= change.before.n_audio()) {
@ -3266,7 +3270,6 @@ Session::load_and_connect_instruments (RouteList& new_routes, bool strict_io, bo
for (RouteList::iterator r = new_routes.begin(); r != new_routes.end(); ++r) {
(*r)->output()->changed.connect_same_thread (*this, boost::bind (&Session::midi_output_change_handler, this, _1, _2, boost::weak_ptr<Route>(*r)));
}
}
void

View File

@ -1846,6 +1846,16 @@ Session::load_routes (const XMLNode& node, int version)
add_routes (new_routes, false, false, PresentationInfo::max_order);
/* re-subscribe to MIDI connection handler */
for (RouteList::iterator r = new_routes.begin(); r != new_routes.end(); ++r) {
boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (*r);
bool is_midi_route = (*r)->n_inputs().n_midi() > 0 && (*r)->n_inputs().n_midi() > 0;
if (mt || is_midi_route) {
(*r)->output()->changed.connect_same_thread (*this, boost::bind (&Session::midi_output_change_handler, this, _1, _2, boost::weak_ptr<Route>(*r)));
}
}
BootMessage (_("Finished adding tracks/busses"));
return 0;