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:
parent
127684c590
commit
03f683d588
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user