From cdd415cdaf1eb8e7df942c55c88db139fb472277 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 9 Oct 2015 11:05:55 -0400 Subject: tweaks to MidiBuffer::push_back() variants 1. there's no reason to make the same logic checks in both the Event and 3-arg variants when the Event version simply calls the 3-arg variant 2. the Event version returned true under all conditions, even if the 3-arg part had failed to push the Event data into the buffer. It now returns true or false, as intended. 3. remove debug output if a MidiBuffer is full during ::push_back(). The cases where this matters emit output of their own, or simply remain silent and queue data later --- libs/ardour/midi_buffer.cc | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) (limited to 'libs/ardour') diff --git a/libs/ardour/midi_buffer.cc b/libs/ardour/midi_buffer.cc index dc8deb7727..71f3e5334c 100644 --- a/libs/ardour/midi_buffer.cc +++ b/libs/ardour/midi_buffer.cc @@ -135,26 +135,15 @@ MidiBuffer::merge_from (const Buffer& src, framecnt_t /*nframes*/, framecnt_t /* bool MidiBuffer::push_back(const Evoral::MIDIEvent& ev) { - const size_t stamp_size = sizeof(TimeType); - - if (_size + stamp_size + ev.size() >= _capacity) { - cerr << "MidiBuffer::push_back failed (buffer is full)" << endl; - PBD::stacktrace (cerr, 20); - return false; - } - - if (!Evoral::midi_event_is_valid(ev.buffer(), ev.size())) { - cerr << "WARNING: MidiBuffer ignoring illegal MIDI event" << endl; - return false; - } - - push_back(ev.time(), ev.size(), ev.buffer()); - - return true; + return push_back (ev.time(), ev.size(), ev.buffer()); } -/** Push an event into the buffer. +/** Push MIDI data into the buffer. + * + * Note that the raw MIDI pointed to by @param data will be COPIED and unmodified. + * That is, the caller still owns it, if it needs freeing it's Not My Problem(TM). + * Realtime safe. * @return false if operation failed (not enough room) */ bool @@ -178,14 +167,10 @@ MidiBuffer::push_back(TimeType time, size_t size, const uint8_t* data) #endif if (_size + stamp_size + size >= _capacity) { - cerr << "MidiBuffer::push_back2 failed (buffer is full; _size = " << _size << " capacity " - << _capacity << " stamp " << stamp_size << " size = " << size << ")" << endl; - PBD::stacktrace (cerr, 20); return false; } if (!Evoral::midi_event_is_valid(data, size)) { - cerr << "WARNING: MidiBuffer ignoring illegal MIDI event" << endl; return false; } -- cgit v1.2.3