From 4c031bd335b94fbeb5f75293f7f49b81000407f7 Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Wed, 13 Jul 2022 22:22:19 -0400 Subject: [PATCH] Don't use `kAudioQueueProperty_IsRunning` as it seems not to be trustworthy. --- OSBindings/Mac/Clock Signal/Audio/CSAudioQueue.m | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/OSBindings/Mac/Clock Signal/Audio/CSAudioQueue.m b/OSBindings/Mac/Clock Signal/Audio/CSAudioQueue.m index d10a3f791..b66a5e371 100644 --- a/OSBindings/Mac/Clock Signal/Audio/CSAudioQueue.m +++ b/OSBindings/Mac/Clock Signal/Audio/CSAudioQueue.m @@ -16,7 +16,7 @@ (void)status; \ } -#define IsDry(x) (x) < 3 +#define IsDry(x) (x) < 2 @implementation CSAudioQueue { AudioQueueRef _audioQueue; @@ -84,6 +84,9 @@ [queue->_queueLock unlock]; const int buffers = atomic_fetch_add(&queue->_enqueuedBuffers, -1) - 1; + if(!buffers) { + OSSGuard(AudioQueuePause(queue->_audioQueue)); + } id delegate = queue.delegate; [queue->_deallocLock unlock]; @@ -135,9 +138,7 @@ OSSGuard(AudioQueueEnqueueBuffer(_audioQueue, newBuffer, 0, NULL)); // Start the queue if it isn't started yet, and there are now some packets waiting. - UInt32 isRunning = 0, bytesReceived = sizeof(UInt32); - OSSGuard(AudioQueueGetProperty(_audioQueue, kAudioQueueProperty_IsRunning, &isRunning, &bytesReceived)); - if(!isRunning && enqueuedBuffers > 2) { + if(enqueuedBuffers > 1) { OSSGuard(AudioQueueStart(_audioQueue, NULL)); }