Fix a deadlock when starting a device fails.

Public issue https://github.com/mackron/miniaudio/issues/399
This commit is contained in:
David Reid
2022-01-13 18:28:40 +10:00
parent 26e2a59ffb
commit 981d05ae8d
2 changed files with 9 additions and 3 deletions
+2 -1
View File
@@ -1,6 +1,7 @@
v0.11.5 - TBD
=============
* Support has been added for automatic stream routing with the AAudio backend.
* Support has been added for automatic stream routing with the AAudio backend.
* A bug has been fixed that results in a deadlock when starting a device.
---------------------------------------------------------------------------------------------------
+7 -2
View File
@@ -39062,13 +39062,18 @@ static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData)
startResult = MA_SUCCESS;
}
/*
If starting was not successful we'll need to loop back to the start and wait for something
to happen (pDevice->wakeupEvent).
*/
if (startResult != MA_SUCCESS) {
pDevice->workResult = startResult;
continue; /* Failed to start. Loop back to the start and wait for something to happen (pDevice->wakeupEvent). */
ma_event_signal(&pDevice->startEvent); /* <-- Always signal the start event so ma_device_start() can return as it'll be waiting on it. */
continue;
}
/* Make sure the state is set appropriately. */
ma_device__set_state(pDevice, ma_device_state_started);
ma_device__set_state(pDevice, ma_device_state_started); /* <-- Set this before signaling the event so that the state is always guaranteed to be good after ma_device_start() has returned. */
ma_event_signal(&pDevice->startEvent);
ma_device__on_notification_started(pDevice);