From a86f966cb4cd1c14ca3b9efb4c7454bf13384f82 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Sat, 4 Jan 2025 22:24:34 -0500 Subject: [PATCH] Treat kAudioQueueErr_CannotStart as ephemeral. --- OSBindings/Mac/Clock Signal/Audio/CSAudioQueue.m | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/OSBindings/Mac/Clock Signal/Audio/CSAudioQueue.m b/OSBindings/Mac/Clock Signal/Audio/CSAudioQueue.m index 22dd52e19e..e2cb115e78 100644 --- a/OSBindings/Mac/Clock Signal/Audio/CSAudioQueue.m +++ b/OSBindings/Mac/Clock Signal/Audio/CSAudioQueue.m @@ -185,7 +185,15 @@ - (void)enqueueAudioBuffer:(const int16_t *)buffer { // Starting is a no-op if the queue is already playing, but it may not have been started // yet, or may have been paused due to a pipeline failure if the producer is running slowly. if(enqueuedBuffers > 1) { - OSSGuard(^{return AudioQueueStart(self->_audioQueue, NULL);}); + OSSGuard(^{ + const OSStatus result = AudioQueueStart(self->_audioQueue, NULL); + if(result == kAudioQueueErr_CannotStart) { + // Accept cannot-start, hoping it's ephemeral; Apple's specific advice is: + // "Sleeping briefly and retrying is recommended". + return kAudioSessionNoError; + } + return result; + }); } [_queueLock unlock]; }