summaryrefslogtreecommitdiff
path: root/libs/ardour/midi_buffer.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2009-10-21 00:53:26 +0000
committerDavid Robillard <d@drobilla.net>2009-10-21 00:53:26 +0000
commit20f7592fab3a24979ab4077405b5e73a34bfeae8 (patch)
tree71febcff3d2f42efde90d41dd7eb0f0484bd757a /libs/ardour/midi_buffer.cc
parente1980eb495c9682794be28cad8bd15b37806d8c3 (diff)
Fix MIDI thru, though why this is any different from audio (monitoring) I don't know.
git-svn-id: svn://localhost/ardour2/branches/3.0@5837 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/midi_buffer.cc')
-rw-r--r--libs/ardour/midi_buffer.cc10
1 files changed, 5 insertions, 5 deletions
diff --git a/libs/ardour/midi_buffer.cc b/libs/ardour/midi_buffer.cc
index 2ff04d111f..d14a9b95e9 100644
--- a/libs/ardour/midi_buffer.cc
+++ b/libs/ardour/midi_buffer.cc
@@ -268,16 +268,14 @@ MidiBuffer::merge_in_place(const MidiBuffer &other)
Evoral::MIDIEvent<TimeType> ev_other (*them);
size_t sz = 0;
- size_t src;
+ ssize_t src = -1;
/* gather up total size of events that are earlier than
the event referenced by "us"
*/
- src = 0;
-
while (them != other.end() && ev_other.time() < (*us).time()) {
- if (!src) {
+ if (src == -1) {
src = them.offset;
}
sz += sizeof (TimeType) + ev_other.size();
@@ -285,10 +283,12 @@ MidiBuffer::merge_in_place(const MidiBuffer &other)
}
if (sz) {
+ assert(src >= 0);
/* move existing */
- memmove (_data + us.offset + sz, _data + us.offset , _size - us.offset);
+ memmove (_data + us.offset + sz, _data + us.offset, _size - us.offset);
/* increase _size */
_size += sz;
+ assert(_size <= _capacity);
/* insert new stuff */
memcpy (_data + us.offset, other._data + src, sz);
/* update iterator to our own events. this is a miserable hack */