From 51e1266532f01dfc9a7af40a3fd9549183f41e54 Mon Sep 17 00:00:00 2001 From: Johnny Date: Fri, 6 Dec 2024 18:28:37 +0800 Subject: [PATCH] fix crash --- BGMApp/BGMApp/BGMAudioDevice.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/BGMApp/BGMApp/BGMAudioDevice.cpp b/BGMApp/BGMApp/BGMAudioDevice.cpp index 5010ac29..d61507f7 100644 --- a/BGMApp/BGMApp/BGMAudioDevice.cpp +++ b/BGMApp/BGMApp/BGMAudioDevice.cpp @@ -57,6 +57,8 @@ BGMAudioDevice::~BGMAudioDevice() bool BGMAudioDevice::CanBeOutputDeviceInBGMApp() const { CFStringRef uid = CopyDeviceUID(); + assert(uid != nullptr); + bool isNullDevice = CFEqual(uid, CFSTR(kBGMNullDeviceUID)); CFRelease(uid); @@ -340,6 +342,9 @@ bool BGMAudioDevice::IsBGMDevice(bool inIncludeUISoundsInstance) const { // Check the device's UID to see whether it's BGMDevice. CFStringRef uid = CopyDeviceUID(); + if (uid == nullptr) { + return isBGMDevice; + } isBGMDevice = CFEqual(uid, CFSTR(kBGMDeviceUID)) ||