mirror of
https://github.com/kyleneideck/BackgroundMusic
synced 2024-11-10 06:34:22 +00:00
Don't throw in BGMPlayThrough::DestroyIOProcIDs if the device has been removed.
Also, default to only aborting debug builds when they log and swallow an exception if the exception was unexpected. That is, the developer didn't realise the code could throw.
This commit is contained in:
parent
129c21a180
commit
467b072a9d
3 changed files with 45 additions and 15 deletions
|
@ -877,7 +877,8 @@
|
|||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
BGM_STOP_DEBUGGER_ON_LOGGED_EXCEPTIONS = 1;
|
||||
BGM_STOP_DEBUGGER_ON_LOGGED_EXCEPTIONS = 0;
|
||||
BGM_STOP_DEBUGGER_ON_LOGGED_UNEXPECTED_EXCEPTIONS = 1;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
|
||||
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES;
|
||||
|
@ -920,6 +921,7 @@
|
|||
"CoreAudio_StopOnAssert=1",
|
||||
"CoreAudio_ThreadStampMessages=1",
|
||||
"BGM_StopDebuggerOnLoggedExceptions=$(BGM_STOP_DEBUGGER_ON_LOGGED_EXCEPTIONS)",
|
||||
"BGM_StopDebuggerOnLoggedUnexpectedExceptions=$(BGM_STOP_DEBUGGER_ON_LOGGED_UNEXPECTED_EXCEPTIONS)",
|
||||
);
|
||||
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
|
||||
|
@ -986,7 +988,8 @@
|
|||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
BGM_STOP_DEBUGGER_ON_LOGGED_EXCEPTIONS = 1;
|
||||
BGM_STOP_DEBUGGER_ON_LOGGED_EXCEPTIONS = 0;
|
||||
BGM_STOP_DEBUGGER_ON_LOGGED_UNEXPECTED_EXCEPTIONS = 1;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
|
||||
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES;
|
||||
|
@ -1029,6 +1032,7 @@
|
|||
"CoreAudio_StopOnAssert=1",
|
||||
"CoreAudio_ThreadStampMessages=1",
|
||||
"BGM_StopDebuggerOnLoggedExceptions=$(BGM_STOP_DEBUGGER_ON_LOGGED_EXCEPTIONS)",
|
||||
"BGM_StopDebuggerOnLoggedUnexpectedExceptions=$(BGM_STOP_DEBUGGER_ON_LOGGED_UNEXPECTED_EXCEPTIONS)",
|
||||
);
|
||||
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
|
||||
|
@ -1060,6 +1064,7 @@
|
|||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
BGM_STOP_DEBUGGER_ON_LOGGED_EXCEPTIONS = 0;
|
||||
BGM_STOP_DEBUGGER_ON_LOGGED_UNEXPECTED_EXCEPTIONS = 0;
|
||||
CLANG_ANALYZER_NONNULL = YES;
|
||||
CLANG_ANALYZER_SECURITY_FLOATLOOPCOUNTER = YES;
|
||||
CLANG_ANALYZER_SECURITY_INSECUREAPI_RAND = YES;
|
||||
|
@ -1099,6 +1104,7 @@
|
|||
"CoreAudio_Debug=0",
|
||||
"CoreAudio_StopOnAssert=0",
|
||||
"BGM_StopDebuggerOnLoggedExceptions=$(BGM_STOP_DEBUGGER_ON_LOGGED_EXCEPTIONS)",
|
||||
"BGM_StopDebuggerOnLoggedUnexpectedExceptions=$(BGM_STOP_DEBUGGER_ON_LOGGED_UNEXPECTED_EXCEPTIONS)",
|
||||
);
|
||||
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
|
||||
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
|
||||
|
|
|
@ -351,17 +351,36 @@ void BGMPlayThrough::DestroyIOProcIDs()
|
|||
|
||||
DebugMsg("BGMPlayThrough::DestroyIOProcIDs: Destroying IOProcs");
|
||||
|
||||
if(mInputDeviceIOProcID != nullptr)
|
||||
auto destroy = [](CAHALAudioDevice& device, const char* deviceName, AudioDeviceIOProcID& ioProcID) {
|
||||
if(ioProcID != nullptr)
|
||||
{
|
||||
mInputDevice.DestroyIOProcID(mInputDeviceIOProcID);
|
||||
mInputDeviceIOProcID = nullptr;
|
||||
try
|
||||
{
|
||||
device.DestroyIOProcID(ioProcID);
|
||||
}
|
||||
catch(CAException e)
|
||||
{
|
||||
if((e.GetError() == kAudioHardwareBadDeviceError) || (e.GetError() == kAudioHardwareBadObjectError))
|
||||
{
|
||||
// This means the IOProc IDs will have already been destroyed, so there's nothing to do.
|
||||
DebugMsg("BGMPlayThrough::DestroyIOProcIDs: Didn't destroy IOProc ID for %s device because "
|
||||
"it's not connected anymore. deviceID = %d",
|
||||
deviceName,
|
||||
device.GetObjectID());
|
||||
}
|
||||
else
|
||||
{
|
||||
ioProcID = nullptr;
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
if(mOutputDeviceIOProcID != nullptr)
|
||||
{
|
||||
mOutputDevice.DestroyIOProcID(mOutputDeviceIOProcID);
|
||||
mOutputDeviceIOProcID = nullptr;
|
||||
ioProcID = nullptr;
|
||||
}
|
||||
};
|
||||
|
||||
destroy(mInputDevice, "input", mInputDeviceIOProcID);
|
||||
destroy(mOutputDevice, "output", mOutputDeviceIOProcID);
|
||||
}
|
||||
|
||||
bool BGMPlayThrough::CheckIOProcsAreStopped() const noexcept
|
||||
|
|
|
@ -165,8 +165,13 @@ namespace BGM_Utils
|
|||
: "Feel free to report this at"),
|
||||
kBGMIssueTrackerURL);
|
||||
|
||||
#if BGM_StopDebuggerOnLoggedExceptions
|
||||
#if BGM_StopDebuggerOnLoggedExceptions || BGM_StopDebuggerOnLoggedUnexpectedExceptions
|
||||
#if !BGM_StopDebuggerOnLoggedExceptions
|
||||
if(!expected)
|
||||
#endif
|
||||
{
|
||||
BGMAssert(false, "CAException");
|
||||
}
|
||||
#endif
|
||||
return e.GetError();
|
||||
}
|
||||
|
@ -183,7 +188,7 @@ namespace BGM_Utils
|
|||
: "Feel free to report this at"),
|
||||
kBGMIssueTrackerURL);
|
||||
|
||||
#if BGM_StopDebuggerOnLoggedExceptions
|
||||
#if BGM_StopDebuggerOnLoggedExceptions || BGM_StopDebuggerOnLoggedUnexpectedExceptions
|
||||
BGMAssert(false, "Unknown exception");
|
||||
#endif
|
||||
return -1;
|
||||
|
|
Loading…
Reference in a new issue