diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 6e242bcdfb..6736a8bf4e 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -2359,6 +2359,7 @@ private: void setup_click (); void setup_click_state (const XMLNode*); void setup_bundles (); + void setup_bundles_rcu (); void port_registry_changed (); void probe_ctrl_surfaces (); diff --git a/libs/ardour/session_bundles.cc b/libs/ardour/session_bundles.cc index f1ca9f8f39..dad73de027 100644 --- a/libs/ardour/session_bundles.cc +++ b/libs/ardour/session_bundles.cc @@ -94,19 +94,17 @@ Session::bundle_by_name (string name) const } void -Session::setup_bundles () +Session::setup_bundles_rcu () { + RCUWriter writer (_bundles); + std::shared_ptr b = writer.get_copy (); - { - RCUWriter writer (_bundles); - std::shared_ptr b = writer.get_copy (); - for (BundleList::iterator i = b->begin(); i != b->end();) { - if (std::dynamic_pointer_cast(*i)) { - ++i; - continue; - } - i = b->erase(i); + for (BundleList::iterator i = b->begin(); i != b->end();) { + if (std::dynamic_pointer_cast(*i)) { + ++i; + continue; } + i = b->erase(i); } std::vector inputs[DataType::num_types]; @@ -158,7 +156,7 @@ Session::setup_bundles () c->add_channel (_("mono"), DataType::AUDIO); c->set_port (0, outputs[DataType::AUDIO][np]); - add_bundle (c, false); + b->push_back (c); } /* stereo output bundles */ @@ -180,7 +178,7 @@ Session::setup_bundles () c->add_channel (_("R"), DataType::AUDIO); c->set_port (1, outputs[DataType::AUDIO][np + 1]); - add_bundle (c, false); + b->push_back (c); } } @@ -200,7 +198,7 @@ Session::setup_bundles () c->add_channel (_("mono"), DataType::AUDIO); c->set_port (0, inputs[DataType::AUDIO][np]); - add_bundle (c, false); + b->push_back (c); } /* stereo input bundles */ @@ -223,7 +221,7 @@ Session::setup_bundles () c->add_channel (_("R"), DataType::AUDIO); c->set_port (1, inputs[DataType::AUDIO][np + 1]); - add_bundle (c, false); + b->push_back (c); } } @@ -241,7 +239,7 @@ Session::setup_bundles () std::shared_ptr c (new Bundle (n, false)); c->add_channel ("", DataType::MIDI); c->set_port (0, inputs[DataType::MIDI][np]); - add_bundle (c, false); + b->push_back (c); } /* MIDI output bundles */ @@ -257,9 +255,14 @@ Session::setup_bundles () std::shared_ptr c (new Bundle (n, true)); c->add_channel ("", DataType::MIDI); c->set_port (0, outputs[DataType::MIDI][np]); - add_bundle (c, false); + b->push_back (c); } + /* RCUWriter leaves scope, commit changes */ +} - // we trust the backend to only calls us if there's a change +void +Session::setup_bundles () +{ + setup_bundles_rcu (); BundleAddedOrRemoved (); /* EMIT SIGNAL */ }