From b37bc5e5b2d597c472a603747ed139cc74107013 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 8 Nov 2011 14:15:28 +0000 Subject: Fix a few SNAFUs in the port matrix related to multi-type bundles (#4454). git-svn-id: svn://localhost/ardour2/branches/3.0@10494 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/bundle.h | 1 + libs/ardour/bundle.cc | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) (limited to 'libs') diff --git a/libs/ardour/ardour/bundle.h b/libs/ardour/ardour/bundle.h index 821dd57896..46b07c48f5 100644 --- a/libs/ardour/ardour/bundle.h +++ b/libs/ardour/ardour/bundle.h @@ -101,6 +101,7 @@ class Bundle : public PBD::ScopedConnectionList bool connected_to (boost::shared_ptr, AudioEngine &); bool has_same_ports (boost::shared_ptr) const; uint32_t type_channel_to_overall (DataType, uint32_t) const; + uint32_t overall_channel_to_type (DataType, uint32_t) const; void set_name (std::string const &); diff --git a/libs/ardour/bundle.cc b/libs/ardour/bundle.cc index d9fc86e2ad..dd4bacdff2 100644 --- a/libs/ardour/bundle.cc +++ b/libs/ardour/bundle.cc @@ -528,11 +528,17 @@ Bundle::operator== (Bundle const & other) * * If t == MIDI and c == 0, then we would return 2, as 2 is the index of the * 0th MIDI channel. + * + * If t == NIL, we just return c. */ uint32_t Bundle::type_channel_to_overall (DataType t, uint32_t c) const { + if (t == DataType::NIL) { + return c; + } + Glib::Mutex::Lock lm (_channel_mutex); vector::const_iterator i = _channel.begin (); @@ -558,3 +564,26 @@ Bundle::type_channel_to_overall (DataType t, uint32_t c) const /* NOTREACHED */ return -1; } + +/** Perform the reverse of type_channel_to_overall */ +uint32_t +Bundle::overall_channel_to_type (DataType t, uint32_t c) const +{ + if (t == DataType::NIL) { + return c; + } + + Glib::Mutex::Lock lm (_channel_mutex); + + uint32_t s = 0; + + vector::const_iterator i = _channel.begin (); + for (uint32_t j = 0; j < c; ++j) { + if (i->type == t) { + ++s; + } + ++i; + } + + return s; +} -- cgit v1.2.3