Skip to content

Commit

Permalink
Merge pull request #1444 from TomHarte/AudioQueueTransients
Browse files Browse the repository at this point in the history
Treat kAudioQueueErr_CannotStart as ephemeral.
  • Loading branch information
TomHarte authored Jan 5, 2025
2 parents 1300546 + a86f966 commit 83a8c72
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion OSBindings/Mac/Clock Signal/Audio/CSAudioQueue.m
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down

0 comments on commit 83a8c72

Please sign in to comment.