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

Public issue https://github.com/mackron/miniaudio/issues/582
This commit is contained in:
David Reid
2022-11-22 16:48:32 +10:00
parent 0ef02e01ee
commit a6ec466efa
+5
View File
@@ -41247,6 +41247,9 @@ MA_API ma_result ma_device_stop(ma_device* pDevice)
return MA_SUCCESS; /* Already stopped. */ 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); 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. */ /* 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; pDevice->playback.inputCacheRemaining = 0;
} }
ma_mutex_unlock(&pDevice->startStopLock); ma_mutex_unlock(&pDevice->startStopLock);
}
ma_mutex_unlock(&pDevice->wasapi.rerouteLock);
return result; return result;
} }