Merge pull request #1742 from ujifgc/fix-wasapi-usb-disconnect

win-wasapi: Fix audio capture after USB sound card unplugging
This commit is contained in:
Jim 2019-04-20 04:11:01 -07:00 committed by GitHub
commit 491abe7f40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,7 @@
#include "enum-wasapi.hpp"
#include <obs-module.h>
#include <obs.h>
#include <util/platform.h>
#include <util/windows/HRError.hpp>
#include <util/windows/ComPtr.hpp>
@ -366,11 +367,18 @@ DWORD WINAPI WASAPISource::ReconnectThread(LPVOID param)
os_set_thread_name("win-wasapi: reconnect thread");
CoInitializeEx(0, COINIT_MULTITHREADED);
obs_monitoring_type type = obs_source_get_monitoring_type(source->source);
obs_source_set_monitoring_type(source->source, OBS_MONITORING_TYPE_NONE);
while (!WaitForSignal(source->stopSignal, RECONNECT_INTERVAL)) {
if (source->TryInitialize())
break;
}
obs_source_set_monitoring_type(source->source, type);
source->reconnectThread = nullptr;
source->reconnecting = false;
return 0;
@ -446,7 +454,7 @@ DWORD WINAPI WASAPISource::CaptureThread(LPVOID param)
bool reconnect = false;
/* Output devices don't signal, so just make it check every 10 ms */
DWORD dur = source->isInputDevice ? INFINITE : 10;
DWORD dur = source->isInputDevice ? RECONNECT_INTERVAL : 10;
HANDLE sigs[2] = {
source->receiveSignal,