Gracefully ignore illegal MIDI events at the buffer level (i.e. from Jack).

Ardour should now be able to more or less tolerate crazy incoming MIDI (except for SYSEX).


git-svn-id: svn://localhost/ardour2/branches/3.0@4592 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
David Robillard 2009-02-16 00:53:26 +00:00
parent 85ab341795
commit fd1a3cfa4c
6 changed files with 19 additions and 10 deletions

View file

@ -135,8 +135,12 @@ MidiBuffer::push_back(const Evoral::MIDIEvent<TimeType>& ev)
<< " stamp size: " << stamp_size << " \n";*/
if (_size + stamp_size + ev.size() >= _capacity) {
cerr << "MidiBuffer::push_back failed (buffer is full)"
<< endl;
cerr << "MidiBuffer::push_back failed (buffer is full)" << endl;
return false;
}
if (!Evoral::midi_event_is_valid(ev.buffer(), ev.size())) {
cerr << "WARNING: MidiBuffer ignoring illegal MIDI event" << endl;
return false;
}
@ -166,6 +170,11 @@ MidiBuffer::push_back(const jack_midi_event_t& ev)
cerr << "MidiBuffer::push_back failed (buffer is full)" << endl;
return false;
}
if (!Evoral::midi_event_is_valid(ev.buffer, ev.size)) {
cerr << "WARNING: MidiBuffer ignoring illegal MIDI event" << endl;
return false;
}
uint8_t* const write_loc = _data + _size;
*((TimeType*)write_loc) = ev.time;