1
0
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:
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;
@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
/*!

View File

@ -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);
}

View File

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