diff options
author | Deal(一线灵) <[email protected]> | 2023-06-28 16:10:49 +0800 |
---|---|---|
committer | GitHub <[email protected]> | 2023-06-28 08:10:49 +0000 |
commit | e714c8fbca7bc4a03be308d43d6d6cd5e57914bc (patch) | |
tree | e363f1789b274e0f9e1a227a36d05d4a05a6ae28 /alc/backends | |
parent | 2da9d168b6bee32376889a394e11981a4515d041 (diff) |
[UWP] Fix crash when probe capture device fail (#868)
* [UWP] Fix crash when probe capture device fail
* [UWP] Also check openDevice to avoid crash
Diffstat (limited to 'alc/backends')
-rw-r--r-- | alc/backends/wasapi.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/alc/backends/wasapi.cpp b/alc/backends/wasapi.cpp index c5282fcb..dccbeba2 100644 --- a/alc/backends/wasapi.cpp +++ b/alc/backends/wasapi.cpp @@ -577,7 +577,8 @@ struct DeviceHelper final : private IMMNotificationClient Platform::String^ devIfPath = devid.empty() ? (flow == eRender ? MediaDevice::GetDefaultAudioRenderId(deviceRole) : MediaDevice::GetDefaultAudioCaptureId(deviceRole)) : ref new Platform::String(devid.data()); - + if (!devIfPath) + return E_POINTER; Concurrency::task<DeviceInformation^> createDeviceOp( DeviceInformation::CreateFromIdAsync(devIfPath, nullptr, DeviceInformationKind::DeviceInterface)); auto status = createDeviceOp.then([&](DeviceInformation^ deviceInfo) @@ -674,6 +675,8 @@ struct DeviceHelper final : private IMMNotificationClient const auto deviceRole = Windows::Media::Devices::AudioDeviceRole::Default; auto DefaultAudioId = flowdir == eRender ? MediaDevice::GetDefaultAudioRenderId(deviceRole) : MediaDevice::GetDefaultAudioCaptureId(deviceRole); + if (!DefaultAudioId) + return defaultId; Concurrency::task<DeviceInformation ^> createDefaultOp(DeviceInformation::CreateFromIdAsync(DefaultAudioId, nullptr, DeviceInformationKind::DeviceInterface)); auto task_status = createDefaultOp.then([&defaultId](DeviceInformation ^ deviceInfo) { |