From 3b2c3907a068fa0cea366a5e1cf47a23abb170ca Mon Sep 17 00:00:00 2001 From: eriktorbjorn Date: Sun, 8 May 2011 07:30:06 +0200 Subject: ALSA: Warn if events or SysEx messages are received when not open. This should make it easier to spot errors like the one spotted in the Queen engine yesterday. The Windows MIDI driver already seems to do something like this; I don't know about the others. --- backends/midi/alsa.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'backends/midi') diff --git a/backends/midi/alsa.cpp b/backends/midi/alsa.cpp index 5110734a18..bc8fab6a56 100644 --- a/backends/midi/alsa.cpp +++ b/backends/midi/alsa.cpp @@ -183,6 +183,11 @@ void MidiDriver_ALSA::close() { } void MidiDriver_ALSA::send(uint32 b) { + if (!_isOpen) { + warning("MidiDriver_ALSA: Got event while not open"); + return; + } + unsigned int midiCmd[4]; ev.type = SND_SEQ_EVENT_OSS; @@ -256,6 +261,11 @@ void MidiDriver_ALSA::send(uint32 b) { } void MidiDriver_ALSA::sysEx(const byte *msg, uint16 length) { + if (!_isOpen) { + warning("MidiDriver_ALSA: Got SysEx while not open"); + return; + } + unsigned char buf[266]; assert(length + 2 <= ARRAYSIZE(buf)); -- cgit v1.2.3