MidiAlsaSeq: protect concurrent sequencer accesses with mutex

The ALSA sequencer interface is not reentrant and thus we can't queue
MIDI events for output from different threads (which happens with multicore
rendering as processOutEvent() is being called by individual note play
handles). We therefore have to care that we don't call the ALSA sequencer
functions concurrently.

Thanks to Benjamin Kusch for providing a testcase.

Closes #531.
This commit is contained in:
Tobias Doerffel
2013-11-20 23:49:13 +01:00
parent e4d18e76d5
commit 87cf991c32
2 changed files with 49 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
/*
* MidiAlsaSeq.h - ALSA-sequencer-client
*
* Copyright (c) 2005-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
* Copyright (c) 2005-2013 Tobias Doerffel <tobydox/at/users.sourceforge.net>
*
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
*
@@ -31,6 +31,7 @@
#include <alsa/asoundlib.h>
#endif
#include <QtCore/QMutex>
#include <QtCore/QThread>
#include <QtCore/QTimer>
@@ -130,6 +131,7 @@ private:
virtual void run();
#ifdef LMMS_HAVE_ALSA
QMutex m_seqMutex;
snd_seq_t * m_seqHandle;
struct Ports
{