win-wasapi: Fix Stop hang

Fix hang when audio capture is active in the background and stopped by
either closing OBS, or switching scene collections.
This commit is contained in:
jpark37
2022-10-01 09:41:53 -07:00
committed by Jim
parent 8a4cf4b739
commit 39183c76b5

View File

@@ -528,9 +528,6 @@ void WASAPISource::Start()
void WASAPISource::Stop()
{
if (!reconnectThread.Valid())
WaitForSingleObject(reconnectSignal, INFINITE);
SetEvent(stopSignal);
blog(LOG_INFO, "WASAPI: Device '%s' Terminated", device_name.c_str());
@@ -538,8 +535,12 @@ void WASAPISource::Stop()
if (rtwq_supported)
SetEvent(receiveSignal);
if (reconnectThread.Valid())
if (reconnectThread.Valid()) {
WaitForSingleObject(idleSignal, INFINITE);
} else {
const HANDLE sigs[] = {reconnectSignal, idleSignal};
WaitForMultipleObjects(_countof(sigs), sigs, false, INFINITE);
}
SetEvent(exitSignal);