diff --git a/OSBindings/Mac/Clock Signal/Audio/CSAudioQueue.m b/OSBindings/Mac/Clock Signal/Audio/CSAudioQueue.m index 2e1ef29e1..a99fdf3b5 100644 --- a/OSBindings/Mac/Clock Signal/Audio/CSAudioQueue.m +++ b/OSBindings/Mac/Clock Signal/Audio/CSAudioQueue.m @@ -15,6 +15,7 @@ { AudioQueueRef _audioQueue; size_t _queuedSamples; + BOOL _hasHad256; } #pragma mark - AudioQueue callbacks @@ -22,7 +23,11 @@ - (void)audioQueue:(AudioQueueRef)theAudioQueue didCallbackWithBuffer:(AudioQueueBufferRef)buffer { size_t samplesInBuffer = (size_t)(buffer->mAudioDataByteSize / sizeof(int16_t)); - if(_queuedSamples >= 128 && _queuedSamples - samplesInBuffer < 128) [self.delegate audioQueueIsRunningDry:self]; + if(_queuedSamples >= 128 && _queuedSamples - samplesInBuffer < 128 && _hasHad256) + { + _hasHad256 = NO; + [self.delegate audioQueueIsRunningDry:self]; + } _queuedSamples -= samplesInBuffer; AudioQueueFreeBuffer(_audioQueue, buffer); @@ -102,6 +107,7 @@ static void audioOutputCallback( AudioQueueBufferRef newBuffer; size_t bufferBytes = lengthInSamples * sizeof(int16_t); _queuedSamples += lengthInSamples; + _hasHad256 |= (_queuedSamples >= 256); AudioQueueAllocateBuffer(_audioQueue, (UInt32)bufferBytes, &newBuffer); memcpy(newBuffer->mAudioData, buffer, bufferBytes);