From 3b11a457a32f315eebf26ac4e3e53d269dbcb602 Mon Sep 17 00:00:00 2001 From: elasota Date: Sun, 19 Jan 2020 19:25:36 -0500 Subject: [PATCH] Fix audio queue consume overrun (caused shutdown crash due to multiple buffers being queued) --- PortabilityLayer/PLSound.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/PortabilityLayer/PLSound.cpp b/PortabilityLayer/PLSound.cpp index 64c40f9..2f86013 100644 --- a/PortabilityLayer/PLSound.cpp +++ b/PortabilityLayer/PLSound.cpp @@ -204,6 +204,13 @@ namespace PortabilityLayer return; case AudioCommandTypes::kCallback: command.m_param.m_callback(this); + + if (m_state != State_Idle) + { + // Child call changed state (i.e. callback called PushBuffer, which triggered a digest) + m_mutex->Unlock(); + return; + } break; default: assert(false); @@ -215,6 +222,8 @@ namespace PortabilityLayer void AudioChannelImpl::DigestBufferCommand(const void *dataPointer) { + assert(m_state == State_Idle); + // At this point, the buffer should already be validated and converted, and the data pointer should point at the data tag uint32_t length; memcpy(&length, dataPointer, 4);