summaryrefslogtreecommitdiff
path: root/libs/ardour/midi_buffer.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2015-10-09 11:05:55 -0400
committerPaul Davis <paul@linuxaudiosystems.com>2015-10-09 11:05:55 -0400
commitcdd415cdaf1eb8e7df942c55c88db139fb472277 (patch)
treeb6a35905b0a4f18c0cf9cfe9b1a7bcb8aea42e00 /libs/ardour/midi_buffer.cc
parent268d53f5028c222d1f3b5d91b186eba52c5db6c8 (diff)
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
Diffstat (limited to 'libs/ardour/midi_buffer.cc')
-rw-r--r--libs/ardour/midi_buffer.cc27
1 files changed, 6 insertions, 21 deletions
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<TimeType>& 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;
}