summaryrefslogtreecommitdiff
path: root/libs/ardour/bundle.cc
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2011-11-08 14:15:28 +0000
committerCarl Hetherington <carl@carlh.net>2011-11-08 14:15:28 +0000
commitb37bc5e5b2d597c472a603747ed139cc74107013 (patch)
treeb78cf5fe7835be197940e52e679e15f5a43a1616 /libs/ardour/bundle.cc
parent420d5d659219088b4eb9d41035997a020adf2afa (diff)
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
Diffstat (limited to 'libs/ardour/bundle.cc')
-rw-r--r--libs/ardour/bundle.cc29
1 files changed, 29 insertions, 0 deletions
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<Channel>::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<Channel>::const_iterator i = _channel.begin ();
+ for (uint32_t j = 0; j < c; ++j) {
+ if (i->type == t) {
+ ++s;
+ }
+ ++i;
+ }
+
+ return s;
+}