Commit 981d05ae authored by David Reid's avatar David Reid

Fix a deadlock when starting a device fails.

Public issue https://github.com/mackron/miniaudio/issues/399
parent 26e2a59f
v0.11.5 - TBD 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.
--------------------------------------------------------------------------------------------------- ---------------------------------------------------------------------------------------------------
......
...@@ -39062,13 +39062,18 @@ static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData) ...@@ -39062,13 +39062,18 @@ static ma_thread_result MA_THREADCALL ma_worker_thread(void* pData)
startResult = MA_SUCCESS; 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) { if (startResult != MA_SUCCESS) {
pDevice->workResult = startResult; 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. */ /* 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_event_signal(&pDevice->startEvent);
ma_device__on_notification_started(pDevice); ma_device__on_notification_started(pDevice);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment