Commit a6ec466e authored by David Reid's avatar David Reid

WASAPI: Don't stop the device while in the middle of rerouting.

Public issue https://github.com/mackron/miniaudio/issues/582
parent 0ef02e01
......@@ -41247,6 +41247,9 @@ MA_API ma_result ma_device_stop(ma_device* pDevice)
return MA_SUCCESS; /* Already stopped. */
}
/* Wait for any rerouting to finish before attempting to stop the device. */
ma_mutex_lock(&pDevice->wasapi.rerouteLock);
{
ma_mutex_lock(&pDevice->startStopLock);
{
/* Starting and stopping are wrapped in a mutex which means we can assert that the device is in a started or paused state. */
......@@ -41295,6 +41298,8 @@ MA_API ma_result ma_device_stop(ma_device* pDevice)
pDevice->playback.inputCacheRemaining = 0;
}
ma_mutex_unlock(&pDevice->startStopLock);
}
ma_mutex_unlock(&pDevice->wasapi.rerouteLock);
return result;
}
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