diff options
author | Carl Hetherington <carl@carlh.net> | 2011-11-08 02:10:56 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2011-11-08 02:10:56 +0000 |
commit | 19e97d1d64e8aa6d87d79d1f6332065992e5e027 (patch) | |
tree | 0b68797f47972b13929236b976035ae95f3c1011 /libs/ardour/bundle.cc | |
parent | 9fa8238d9d4ebda14d60cc2256d721a0405b5fa0 (diff) |
Attempt to fix some confusions caused by bundles containing
different types of port; if we loop over N MIDI channels of
a mixed bundle, for example, we must convert 0...N to the
indices of the channels within the bundle. Also remove the
hack of creating new bundles to contain a subset of another
bundle's ports; if you do this, any signals emitted by the
other bundle are ignored. Should fix #4454.
git-svn-id: svn://localhost/ardour2/branches/3.0@10490 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/bundle.cc')
-rw-r--r-- | libs/ardour/bundle.cc | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/libs/ardour/bundle.cc b/libs/ardour/bundle.cc index d8666c5bbb..d9fc86e2ad 100644 --- a/libs/ardour/bundle.cc +++ b/libs/ardour/bundle.cc @@ -517,3 +517,44 @@ Bundle::operator== (Bundle const & other) { return _channel == other._channel; } + +/** Given an index of a channel as the nth channel of a particular type, + * return an index of that channel when considering channels of all types. + * + * e.g. given a bundle with channels: + * fred [audio] + * jim [audio] + * sheila [midi] + * + * If t == MIDI and c == 0, then we would return 2, as 2 is the index of the + * 0th MIDI channel. + */ + +uint32_t +Bundle::type_channel_to_overall (DataType t, uint32_t c) const +{ + Glib::Mutex::Lock lm (_channel_mutex); + + vector<Channel>::const_iterator i = _channel.begin (); + + uint32_t o = 0; + + while (1) { + + assert (i != _channel.end ()); + + if (i->type != t) { + ++i; + } else { + if (c == 0) { + return o; + } + --c; + } + + ++o; + } + + /* NOTREACHED */ + return -1; +} |