mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-25 03:32:01 +00:00
Sought to reduce chattiness.
This commit is contained in:
parent
1a57e89ff0
commit
c105f2acd9
@ -11,7 +11,8 @@
|
|||||||
@class CSAudioQueue;
|
@class CSAudioQueue;
|
||||||
|
|
||||||
@protocol CSAudioQueueDelegate
|
@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
|
@end
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -14,13 +14,15 @@
|
|||||||
@implementation CSAudioQueue
|
@implementation CSAudioQueue
|
||||||
{
|
{
|
||||||
AudioQueueRef _audioQueue;
|
AudioQueueRef _audioQueue;
|
||||||
|
size_t _queuedSamples;
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma mark - AudioQueue callbacks
|
#pragma mark - AudioQueue callbacks
|
||||||
|
|
||||||
- (void)audioQueue:(AudioQueueRef)theAudioQueue didCallbackWithBuffer:(AudioQueueBufferRef)buffer
|
- (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);
|
AudioQueueFreeBuffer(_audioQueue, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,6 +99,7 @@ static void audioOutputCallback(
|
|||||||
{
|
{
|
||||||
AudioQueueBufferRef newBuffer;
|
AudioQueueBufferRef newBuffer;
|
||||||
size_t bufferBytes = lengthInSamples * sizeof(int16_t);
|
size_t bufferBytes = lengthInSamples * sizeof(int16_t);
|
||||||
|
_queuedSamples += lengthInSamples;
|
||||||
|
|
||||||
AudioQueueAllocateBuffer(_audioQueue, (UInt32)bufferBytes, &newBuffer);
|
AudioQueueAllocateBuffer(_audioQueue, (UInt32)bufferBytes, &newBuffer);
|
||||||
memcpy(newBuffer->mAudioData, buffer, bufferBytes);
|
memcpy(newBuffer->mAudioData, buffer, bufferBytes);
|
||||||
|
Loading…
Reference in New Issue
Block a user