From 39183c76b5304486df76584dad78348e2b3fad01 Mon Sep 17 00:00:00 2001 From: jpark37 Date: Sat, 1 Oct 2022 09:41:53 -0700 Subject: [PATCH] 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. --- plugins/win-wasapi/win-wasapi.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/win-wasapi/win-wasapi.cpp b/plugins/win-wasapi/win-wasapi.cpp index 2dcc858f7..85c252e66 100644 --- a/plugins/win-wasapi/win-wasapi.cpp +++ b/plugins/win-wasapi/win-wasapi.cpp @@ -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);