mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-25 18:30:21 +00:00
Sought to reduce chattiness.
This commit is contained in:
parent
1a57e89ff0
commit
c105f2acd9
@ -11,7 +11,8 @@
|
||||
@class CSAudioQueue;
|
||||
|
||||
@protocol CSAudioQueueDelegate
|
||||
- (void)audioQueueDidCompleteBuffer:(nonnull CSAudioQueue *)audioQueue;
|
||||
- (void)audioQueueDidCompleteBuffer:(nonnull CSAudioQueue *)audioQueue; // TODO: rename this to audioQueueNeedsData or something, to indicate that
|
||||
// it means something more along the lines of 'may run out soon'
|
||||
@end
|
||||
|
||||
/*!
|
||||
|
@ -14,13 +14,15 @@
|
||||
@implementation CSAudioQueue
|
||||
{
|
||||
AudioQueueRef _audioQueue;
|
||||
size_t _queuedSamples;
|
||||
}
|
||||
|
||||
#pragma mark - AudioQueue callbacks
|
||||
|
||||
- (void)audioQueue:(AudioQueueRef)theAudioQueue didCallbackWithBuffer:(AudioQueueBufferRef)buffer
|
||||
{
|
||||
[self.delegate audioQueueDidCompleteBuffer:self];
|
||||
_queuedSamples -= (size_t)(buffer->mAudioDataByteSize / sizeof(int16_t));
|
||||
if(_queuedSamples < 128) [self.delegate audioQueueDidCompleteBuffer:self];
|
||||
AudioQueueFreeBuffer(_audioQueue, buffer);
|
||||
}
|
||||
|
||||
@ -97,6 +99,7 @@ static void audioOutputCallback(
|
||||
{
|
||||
AudioQueueBufferRef newBuffer;
|
||||
size_t bufferBytes = lengthInSamples * sizeof(int16_t);
|
||||
_queuedSamples += lengthInSamples;
|
||||
|
||||
AudioQueueAllocateBuffer(_audioQueue, (UInt32)bufferBytes, &newBuffer);
|
||||
memcpy(newBuffer->mAudioData, buffer, bufferBytes);
|
||||
|
Loading…
Reference in New Issue
Block a user