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/bundle.cc | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'libs/ardour/bundle.cc') 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