From 6cf22c54dc843b0a17b4cb399afc7b52fba0b63d Mon Sep 17 00:00:00 2001 From: jp9000 Date: Sat, 6 Feb 2021 10:41:19 -0800 Subject: [PATCH] win-waspi: Make sure to unregister notification obj Fixes a bug where the notify object existed after source deletion --- 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 bf5175aec..268e82e1b 100644 --- a/plugins/win-wasapi/win-wasapi.cpp +++ b/plugins/win-wasapi/win-wasapi.cpp @@ -27,6 +27,7 @@ class WASAPISource { ComPtr client; ComPtr capture; ComPtr render; + ComPtr enumerator; ComPtr notify; obs_source_t *source; @@ -62,7 +63,7 @@ class WASAPISource { inline void Stop(); void Reconnect(); - bool InitDevice(IMMDeviceEnumerator *enumerator); + bool InitDevice(); void InitName(); void InitClient(); void InitRender(); @@ -180,6 +181,7 @@ inline void WASAPISource::Stop() inline WASAPISource::~WASAPISource() { + enumerator->UnregisterEndpointNotificationCallback(notify); Stop(); } @@ -204,7 +206,7 @@ void WASAPISource::Update(obs_data_t *settings) Start(); } -bool WASAPISource::InitDevice(IMMDeviceEnumerator *enumerator) +bool WASAPISource::InitDevice() { HRESULT res; @@ -362,7 +364,6 @@ void WASAPISource::InitCapture() void WASAPISource::Initialize() { - ComPtr enumerator; HRESULT res; res = CoCreateInstance(__uuidof(MMDeviceEnumerator), nullptr, @@ -371,7 +372,7 @@ void WASAPISource::Initialize() if (FAILED(res)) throw HRError("Failed to create enumerator", res); - if (!InitDevice(enumerator)) + if (!InitDevice()) return; device_name = GetDeviceName(device);