diff options
author | Chris Robinson <[email protected]> | 2023-08-31 04:25:03 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-08-31 04:25:03 -0700 |
commit | d2d6365b3f965922f6c25198bcd9de30ccf9f6bb (patch) | |
tree | 7afffc6cc23777c4b8cd56bbfcf5e7436d23d3c0 | |
parent | c53ee243ec5af8392a15d4e315b36dec4b5f41cf (diff) |
Handle a null string in DeviceHelper::OnDefaultDeviceChanged
-rw-r--r-- | alc/backends/wasapi.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp index 96c56fa8..c9ea7980 100644 --- a/alc/backends/wasapi.cpp +++ b/alc/backends/wasapi.cpp @@ -526,18 +526,18 @@ struct DeviceHelper final : private IMMNotificationClient if(role != eMultimedia) return S_OK; + const std::wstring_view devid{pwstrDefaultDeviceId ? pwstrDefaultDeviceId + : std::wstring_view{}}; if(flow == eRender) { - DeviceListLock{gDeviceList}.setPlaybackDefaultId(pwstrDefaultDeviceId); - const std::string msg{"Default playback device changed: "+ - wstr_to_utf8(pwstrDefaultDeviceId)}; + DeviceListLock{gDeviceList}.setPlaybackDefaultId(devid); + const std::string msg{"Default playback device changed: " + wstr_to_utf8(devid)}; alc::Event(alc::EventType::DefaultDeviceChanged, alc::DeviceType::Playback, msg); } else if(flow == eCapture) { - DeviceListLock{gDeviceList}.setCaptureDefaultId(pwstrDefaultDeviceId); - const std::string msg{"Default capture device changed: "+ - wstr_to_utf8(pwstrDefaultDeviceId)}; + DeviceListLock{gDeviceList}.setCaptureDefaultId(devid); + const std::string msg{"Default capture device changed: " + wstr_to_utf8(devid)}; alc::Event(alc::EventType::DefaultDeviceChanged, alc::DeviceType::Capture, msg); } return S_OK; |