1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-12-25 18:30:21 +00:00

Cemented new meaningof the audio queue delegate callout.

This commit is contained in:
Thomas Harte 2016-10-17 08:18:32 -04:00
parent 988bbb5ab1
commit f6b6ec7009
3 changed files with 6 additions and 5 deletions

View File

@ -11,8 +11,7 @@
@class CSAudioQueue; @class CSAudioQueue;
@protocol CSAudioQueueDelegate @protocol CSAudioQueueDelegate
- (void)audioQueueDidCompleteBuffer:(nonnull CSAudioQueue *)audioQueue; // TODO: rename this to audioQueueNeedsData or something, to indicate that - (void)audioQueueIsRunningDry:(nonnull CSAudioQueue *)audioQueue;
// it means something more along the lines of 'may run out soon'
@end @end
/*! /*!

View File

@ -21,8 +21,10 @@
- (void)audioQueue:(AudioQueueRef)theAudioQueue didCallbackWithBuffer:(AudioQueueBufferRef)buffer - (void)audioQueue:(AudioQueueRef)theAudioQueue didCallbackWithBuffer:(AudioQueueBufferRef)buffer
{ {
_queuedSamples -= (size_t)(buffer->mAudioDataByteSize / sizeof(int16_t)); size_t samplesInBuffer = (size_t)(buffer->mAudioDataByteSize / sizeof(int16_t));
if(_queuedSamples < 128) [self.delegate audioQueueDidCompleteBuffer:self]; if(_queuedSamples >= 128 && _queuedSamples - samplesInBuffer < 128) [self.delegate audioQueueIsRunningDry:self];
_queuedSamples -= samplesInBuffer;
AudioQueueFreeBuffer(_audioQueue, buffer); AudioQueueFreeBuffer(_audioQueue, buffer);
} }

View File

@ -148,7 +148,7 @@ class MachineDocument:
} }
// MARK: CSAudioQueueDelegate // MARK: CSAudioQueueDelegate
final func audioQueueDidCompleteBuffer(_ audioQueue: CSAudioQueue) { final func audioQueueIsRunningDry(_ audioQueue: CSAudioQueue) {
bestEffortUpdater.update() bestEffortUpdater.update()
} }