1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-29 12:50:28 +00:00

Gave the audio queue something a lot like a spin lock on waiting to pipe out audio.

This commit is contained in:
Thomas Harte 2016-01-18 19:57:18 -06:00
parent 127684c590
commit 03f683d588

View File

@ -140,7 +140,11 @@ static void audioOutputCallback(
- (void)enqueueAudioBuffer:(const int16_t *)buffer numberOfSamples:(size_t)lengthInSamples
{
while(1)
{
[_writeLock lockWhenCondition:AudioQueueCanWrite];
if((_audioStreamReadPosition + AudioQueueStreamLength) - _audioStreamWritePosition >= lengthInSamples)
{
size_t samplesBeforeOverflow = AudioQueueStreamLength - (_audioStreamWritePosition % AudioQueueStreamLength);
if(samplesBeforeOverflow < lengthInSamples)
@ -155,6 +159,13 @@ static void audioOutputCallback(
_audioStreamWritePosition += lengthInSamples;
[_writeLock unlockWithCondition:[self writeLockCondition]];
break;
}
else
{
[_writeLock unlockWithCondition:AudioQueueWait];
}
}
}
- (NSInteger)writeLockCondition