summaryrefslogtreecommitdiff
path: root/libs/ardour/bundle.cc
diff options
context:
space:
mode:
authorJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>2017-08-29 10:33:53 +0200
committerJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>2017-08-29 10:53:41 +0200
commit41c5913b9150c6cf02c5b3b2b936635c3b87ebfe (patch)
treead1a0f6bfa34b9642d6f4e0a99b69d8c78220ead /libs/ardour/bundle.cc
parent6d0b0099956a97725cc207ed59c84e6fddc239f6 (diff)
Make Bundle::disconnect() more robust
Instead of asserting or crashing if the number of channels of both bundles don't match, just try to disconnect as much as possible.
Diffstat (limited to 'libs/ardour/bundle.cc')
-rw-r--r--libs/ardour/bundle.cc23
1 files changed, 15 insertions, 8 deletions
diff --git a/libs/ardour/bundle.cc b/libs/ardour/bundle.cc
index b12455b38b..081d790b6c 100644
--- a/libs/ardour/bundle.cc
+++ b/libs/ardour/bundle.cc
@@ -361,16 +361,23 @@ Bundle::connect (boost::shared_ptr<Bundle> other, AudioEngine & engine,
void
Bundle::disconnect (boost::shared_ptr<Bundle> other, AudioEngine & engine)
{
- uint32_t const N = n_total();
- assert (N == other->n_total());
+ ChanCount our_count = nchannels();
+ ChanCount other_count = other->nchannels();
- for (uint32_t i = 0; i < N; ++i) {
- Bundle::PortList const & our_ports = channel_ports (i);
- Bundle::PortList const & other_ports = other->channel_ports (i);
+ for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) {
+ uint32_t N = min(our_count.n(*t), other_count.n(*t));
+ for (uint32_t i = 0; i < N; ++i) {
+ Bundle::PortList const & our_ports =
+ channel_ports (type_channel_to_overall(*t, i));
+ Bundle::PortList const & other_ports =
+ other->channel_ports (other->type_channel_to_overall(*t, i));
- for (Bundle::PortList::const_iterator j = our_ports.begin(); j != our_ports.end(); ++j) {
- for (Bundle::PortList::const_iterator k = other_ports.begin(); k != other_ports.end(); ++k) {
- engine.disconnect (*j, *k);
+ for (Bundle::PortList::const_iterator j = our_ports.begin();
+ j != our_ports.end(); ++j) {
+ for (Bundle::PortList::const_iterator k = other_ports.begin();
+ k != other_ports.end(); ++k) {
+ engine.disconnect (*j, *k);
+ }
}
}
}