From bbce6880d7916f043341cbb90fc9f437ec40843f Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Wed, 26 Jan 2022 15:42:28 -0800 Subject: [PATCH] Core Audio output: Add a quick safety fix Add a safety fix for pausing and shutting down, so that we don't call into AUAudioUnit's stopHardware function unless the stream has already been started by the output. Signed-off-by: Christopher Snowhill --- Audio/Output/OutputCoreAudio.m | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Audio/Output/OutputCoreAudio.m b/Audio/Output/OutputCoreAudio.m index d1d89549e..065e65c0d 100644 --- a/Audio/Output/OutputCoreAudio.m +++ b/Audio/Output/OutputCoreAudio.m @@ -755,7 +755,8 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const listenerapplied = NO; } if (_au) { - [_au stopHardware]; + if (started) + [_au stopHardware]; _au = nil; } if (running) @@ -791,7 +792,8 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const - (void)pause { paused = YES; - [_au stopHardware]; + if (started) + [_au stopHardware]; } - (void)resume @@ -799,6 +801,7 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const NSError *err; [_au startHardwareAndReturnError:&err]; paused = NO; + started = YES; } - (void)sustainHDCD