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:
parent
85ab341795
commit
fd1a3cfa4c
|
@ -99,7 +99,8 @@ class MidiSource : public Source
|
|||
protected:
|
||||
virtual void flush_midi() = 0;
|
||||
|
||||
virtual nframes_t read_unlocked (MidiRingBuffer<nframes_t>& dst, nframes_t start, nframes_t cnt, nframes_t stamp_offset, nframes_t negative_stamp_offset) const = 0;
|
||||
virtual nframes_t read_unlocked (MidiRingBuffer<nframes_t>& dst, nframes_t start, nframes_t cnt,
|
||||
nframes_t stamp_offset, nframes_t negative_stamp_offset) const = 0;
|
||||
virtual nframes_t write_unlocked (MidiRingBuffer<nframes_t>& dst, nframes_t cnt) = 0;
|
||||
|
||||
mutable Glib::Mutex _lock;
|
||||
|
|
|
@ -95,7 +95,6 @@ protected:
|
|||
int _set_state (const XMLNode&, bool call_base);
|
||||
|
||||
private:
|
||||
|
||||
void write_controller_messages(MidiBuffer& buf,
|
||||
nframes_t start_frame, nframes_t end_frame, nframes_t nframes, nframes_t offset);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <pbd/enumwriter.h>
|
||||
#include <midi++/events.h>
|
||||
#include <evoral/midi_util.h>
|
||||
|
||||
#include <ardour/midi_track.h>
|
||||
#include <ardour/midi_diskstream.h>
|
||||
|
@ -662,11 +663,10 @@ MidiTrack::midi_panic()
|
|||
bool
|
||||
MidiTrack::write_immediate_event(size_t size, const uint8_t* buf)
|
||||
{
|
||||
/*printf("Write immediate event: ");
|
||||
for (size_t i=0; i < size; ++i) {
|
||||
printf("%X ", buf[i]);
|
||||
if (!Evoral::midi_event_is_valid(buf, size)) {
|
||||
cerr << "WARNING: Ignoring illegal immediate MIDI event" << endl;
|
||||
return false;
|
||||
}
|
||||
printf("\n");*/
|
||||
const uint32_t type = EventTypeMap::instance().midi_event_type(buf[0]);
|
||||
return (_immediate_events.write(0, type, size, buf) == size);
|
||||
}
|
||||
|
|
|
@ -228,7 +228,7 @@ SMF::append_event_delta(uint32_t delta_t, uint32_t size, const uint8_t* buf)
|
|||
} printf("\n");*/
|
||||
|
||||
if (!midi_event_is_valid(buf, size)) {
|
||||
cerr << "WARNING: Ignoring illegal MIDI event" << endl;
|
||||
cerr << "WARNING: SMF ignoring illegal MIDI event" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -581,7 +581,7 @@ Sequence<Time>::append(const Event<Time>& event)
|
|||
assert(_writing);
|
||||
|
||||
if (!midi_event_is_valid(ev.buffer(), ev.size())) {
|
||||
cerr << "WARNING: Ignoring illegal MIDI event" << endl;
|
||||
cerr << "WARNING: Sequence ignoring illegal MIDI event" << endl;
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user