From 20f7592fab3a24979ab4077405b5e73a34bfeae8 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Wed, 21 Oct 2009 00:53:26 +0000 Subject: 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 --- libs/ardour/midi_buffer.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'libs/ardour/midi_buffer.cc') 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 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 */ -- cgit v1.2.3