From 95c9cd679bf8f866e3d6e474f0db0730ba0b7bbb Mon Sep 17 00:00:00 2001 From: Eism Date: Tue, 4 Jul 2023 17:43:39 +0300 Subject: [PATCH] Checking devices for null --- .../audio/internal/platform/win/audiodeviceslistener.cpp | 6 ++++-- .../audio/internal/platform/win/audiodeviceslistener.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/framework/audio/internal/platform/win/audiodeviceslistener.cpp b/src/framework/audio/internal/platform/win/audiodeviceslistener.cpp index 2b13fcb64cadd..54e0d7b96872e 100644 --- a/src/framework/audio/internal/platform/win/audiodeviceslistener.cpp +++ b/src/framework/audio/internal/platform/win/audiodeviceslistener.cpp @@ -118,11 +118,13 @@ HRESULT AudioDevicesListener::OnDefaultDeviceChanged(EDataFlow flow, ERole role, return S_OK; } - if (m_previousIdString == new_default_device_id) { + winrt::hstring newDefaultDeviceIdString = new_default_device_id ? new_default_device_id : winrt::hstring(); + + if (m_previousDefaultDeviceId == newDefaultDeviceIdString) { return S_OK; } - m_previousIdString = new_default_device_id; + m_previousDefaultDeviceId = newDefaultDeviceIdString; m_defaultDeviceChanged.notify(); m_devicesChanged.notify(); diff --git a/src/framework/audio/internal/platform/win/audiodeviceslistener.h b/src/framework/audio/internal/platform/win/audiodeviceslistener.h index 7b64d574e2a6d..d77cd7c539a80 100644 --- a/src/framework/audio/internal/platform/win/audiodeviceslistener.h +++ b/src/framework/audio/internal/platform/win/audiodeviceslistener.h @@ -47,7 +47,7 @@ class AudioDevicesListener : public IMMNotificationClient STDMETHOD(OnPropertyValueChanged)(LPCWSTR device_id, const PROPERTYKEY key); winrt::com_ptr m_deviceEnumerator; - winrt::hstring m_previousIdString; + winrt::hstring m_previousDefaultDeviceId; async::Notification m_devicesChanged; async::Notification m_defaultDeviceChanged;