summaryrefslogtreecommitdiff
path: root/libs/ardour/bundle.cc
diff options
context:
space:
mode:
authorJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>2017-08-28 12:13:01 +0200
committerJulien "_FrnchFrgg_" RIVAUD <frnchfrgg@free.fr>2017-08-28 14:10:22 +0200
commit6039b44c0a0dea471dd81c3bc2878fd6049de238 (patch)
tree33056cb65f3d2b7b3a0a6c2696e0fb7f4564b9b6 /libs/ardour/bundle.cc
parente07bb078994c7e36f25c49c59c5c9627dc2aff8e (diff)
Make Bundle::connected_to() able to check only a single DataType
Also use the same iteration logic than in Bundle::connect to avoid mismatched port types.
Diffstat (limited to 'libs/ardour/bundle.cc')
-rw-r--r--libs/ardour/bundle.cc41
1 files changed, 30 insertions, 11 deletions
diff --git a/libs/ardour/bundle.cc b/libs/ardour/bundle.cc
index bdf2446077..33f71dcecd 100644
--- a/libs/ardour/bundle.cc
+++ b/libs/ardour/bundle.cc
@@ -434,30 +434,49 @@ 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. */
bool
-Bundle::connected_to (boost::shared_ptr<Bundle> other, AudioEngine & engine)
+Bundle::connected_to (boost::shared_ptr<Bundle> other, AudioEngine & engine,
+ DataType type, bool exclusive)
{
- if (_ports_are_inputs == other->_ports_are_inputs || nchannels() != other->nchannels()) {
+ if (_ports_are_inputs == other->_ports_are_inputs)
return false;
+
+ if (type == DataType::NIL) {
+ for (DataType::iterator t = DataType::begin();
+ t != DataType::end(); ++t) {
+ if (!connected_to(other, engine, *t))
+ return false;
+ }
+ return true;
}
- for (uint32_t i = 0; i < n_total(); ++i) {
- Bundle::PortList const & A = channel_ports (i);
- Bundle::PortList const & B = other->channel_ports (i);
+ uint32_t N = nchannels().n(type);
+ if (other->nchannels().n(type) != N)
+ return false;
+
+ for (uint32_t i = 0; i < N; ++i) {
+ Bundle::PortList const & our_ports =
+ channel_ports (type_channel_to_overall(type, i));
+ Bundle::PortList const & other_ports =
+ other->channel_ports (other->type_channel_to_overall(type, i));
- for (uint32_t j = 0; j < A.size(); ++j) {
- for (uint32_t k = 0; k < B.size(); ++k) {
+ for (Bundle::PortList::const_iterator j = our_ports.begin();
+ j != our_ports.end(); ++j) {
+ boost::shared_ptr<Port> p = engine.get_port_by_name(*j);
- boost::shared_ptr<Port> p = engine.get_port_by_name (A[j]);
- boost::shared_ptr<Port> q = engine.get_port_by_name (B[k]);
+ for (Bundle::PortList::const_iterator k = other_ports.begin();
+ k != other_ports.end(); ++k) {
+ boost::shared_ptr<Port> q = engine.get_port_by_name(*k);
if (!p && !q) {
return false;
}
- if (p && !p->connected_to (B[k])) {
+ if (p && !p->connected_to (*k)) {
return false;
- } else if (q && !q->connected_to (A[j])) {
+ } else if (q && !q->connected_to (*j)) {
return false;
}
}