Skip to content

Commit

Permalink
win-wasapi: Fix Stop hang
Browse files Browse the repository at this point in the history
Fix hang when audio capture is active in the background and stopped by
either closing OBS, or switching scene collections.
  • Loading branch information
jpark37 authored and jp9000 committed Oct 1, 2022
1 parent 05b6346 commit d21891b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions plugins/win-wasapi/win-wasapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -528,18 +528,19 @@ 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());

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);

Expand Down

0 comments on commit d21891b

Please sign in to comment.