mirror of
https://github.com/TomHarte/CLK.git
synced 2024-12-25 03:32:01 +00:00
Cemented new meaningof the audio queue delegate callout.
This commit is contained in:
parent
988bbb5ab1
commit
f6b6ec7009
@ -11,8 +11,7 @@
|
||||
@class CSAudioQueue;
|
||||
|
||||
@protocol CSAudioQueueDelegate
|
||||
- (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'
|
||||
- (void)audioQueueIsRunningDry:(nonnull CSAudioQueue *)audioQueue;
|
||||
@end
|
||||
|
||||
/*!
|
||||
|
@ -21,8 +21,10 @@
|
||||
|
||||
- (void)audioQueue:(AudioQueueRef)theAudioQueue didCallbackWithBuffer:(AudioQueueBufferRef)buffer
|
||||
{
|
||||
_queuedSamples -= (size_t)(buffer->mAudioDataByteSize / sizeof(int16_t));
|
||||
if(_queuedSamples < 128) [self.delegate audioQueueDidCompleteBuffer:self];
|
||||
size_t samplesInBuffer = (size_t)(buffer->mAudioDataByteSize / sizeof(int16_t));
|
||||
if(_queuedSamples >= 128 && _queuedSamples - samplesInBuffer < 128) [self.delegate audioQueueIsRunningDry:self];
|
||||
_queuedSamples -= samplesInBuffer;
|
||||
|
||||
AudioQueueFreeBuffer(_audioQueue, buffer);
|
||||
}
|
||||
|
||||
|
@ -148,7 +148,7 @@ class MachineDocument:
|
||||
}
|
||||
|
||||
// MARK: CSAudioQueueDelegate
|
||||
final func audioQueueDidCompleteBuffer(_ audioQueue: CSAudioQueue) {
|
||||
final func audioQueueIsRunningDry(_ audioQueue: CSAudioQueue) {
|
||||
bestEffortUpdater.update()
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user