diff --git a/src/mididevice.cpp b/src/mididevice.cpp index 9762e49..6959b41 100644 --- a/src/mididevice.cpp +++ b/src/mididevice.cpp @@ -163,6 +163,8 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign return; } + m_MIDISpinLock.Acquire (); + u8 ucStatus = pMessage[0]; u8 ucChannel = ucStatus & 0x0F; u8 ucType = ucStatus >> 4; @@ -313,6 +315,7 @@ void CMIDIDevice::MIDIMessageHandler (const u8 *pMessage, size_t nLength, unsign } } } + m_MIDISpinLock.Release (); } void CMIDIDevice::AddDevice (const char *pDeviceName) diff --git a/src/mididevice.h b/src/mididevice.h index 196a61b..1bd5396 100644 --- a/src/mididevice.h +++ b/src/mididevice.h @@ -27,6 +27,7 @@ #include #include #include +#include class CMiniDexed; @@ -65,6 +66,8 @@ private: typedef std::unordered_map TDeviceMap; static TDeviceMap s_DeviceMap; + + CSpinLock m_MIDISpinLock; }; #endif