13
0

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
This commit is contained in:
Paul Davis 2015-10-09 11:05:55 -04:00
parent 268d53f502
commit cdd415cdaf

View File

@ -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;
}