From 50c6a90d248f1cfe74c3cdbccfdc79e3e43a471f Mon Sep 17 00:00:00 2001 From: "Julien \"_FrnchFrgg_\" RIVAUD" Date: Mon, 28 Aug 2017 12:18:02 +0200 Subject: Make Bundle::connected_to() optionally check for exclusivity If the new optional argument is true, then the first bundle will also check if it has other connections than to the given bundle. --- libs/ardour/bundle.cc | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'libs/ardour/bundle.cc') diff --git a/libs/ardour/bundle.cc b/libs/ardour/bundle.cc index 33f71dcecd..b12455b38b 100644 --- a/libs/ardour/bundle.cc +++ b/libs/ardour/bundle.cc @@ -434,8 +434,12 @@ Bundle::emit_changed (Change c) } } -/* @return true if a Bundle is connected to another. - * @param type: if not NIL, restrict the check to channels of that type. */ +/** This must not be called in code executed as a response to a backend event, + * as it may query the backend in the same thread where it's waiting for us. + * @return true if a Bundle is connected to another. + * @param type: if not NIL, restrict the check to channels of that type. + * @param exclusive: if true, additionally check if the bundle is connected + * only to |other|, and return false if not. */ bool Bundle::connected_to (boost::shared_ptr other, AudioEngine & engine, DataType type, bool exclusive) @@ -446,7 +450,7 @@ Bundle::connected_to (boost::shared_ptr other, AudioEngine & engine, if (type == DataType::NIL) { for (DataType::iterator t = DataType::begin(); t != DataType::end(); ++t) { - if (!connected_to(other, engine, *t)) + if (!connected_to(other, engine, *t, exclusive)) return false; } return true; @@ -456,6 +460,8 @@ Bundle::connected_to (boost::shared_ptr other, AudioEngine & engine, if (other->nchannels().n(type) != N) return false; + vector port_connections; + for (uint32_t i = 0; i < N; ++i) { Bundle::PortList const & our_ports = channel_ports (type_channel_to_overall(type, i)); @@ -480,6 +486,13 @@ Bundle::connected_to (boost::shared_ptr other, AudioEngine & engine, return false; } } + + if (exclusive && p) { + port_connections.clear(); + p->get_connections(port_connections); + if (port_connections.size() != other_ports.size()) + return false; + } } } -- cgit v1.2.3