Cog Audio: Finally fix track glitching on lots of tiny tracks
parent
61d096aef3
commit
8eb2b4c4a3
|
@ -125,6 +125,13 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
{
|
{
|
||||||
long bytesBuffered = [[outputController buffer] bufferedLength];
|
long bytesBuffered = [[outputController buffer] bufferedLength];
|
||||||
bytesBuffered += atomic_load_explicit(&bytesRendered, memory_order_relaxed);
|
bytesBuffered += atomic_load_explicit(&bytesRendered, memory_order_relaxed);
|
||||||
|
if ([outputController chainQueueHasTracks])
|
||||||
|
{
|
||||||
|
if (bytesBuffered < CHUNK_SIZE)
|
||||||
|
bytesBuffered = 0;
|
||||||
|
else
|
||||||
|
bytesBuffered -= CHUNK_SIZE;
|
||||||
|
}
|
||||||
[delayedEvents addObject:[NSNumber numberWithLong:bytesBuffered]];
|
[delayedEvents addObject:[NSNumber numberWithLong:bytesBuffered]];
|
||||||
delayedEventsPopped = NO;
|
delayedEventsPopped = NO;
|
||||||
if (!started) {
|
if (!started) {
|
||||||
|
@ -429,8 +436,7 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
|
|
||||||
amountToRead = inputData->mBuffers[0].mDataByteSize;
|
amountToRead = inputData->mBuffers[0].mDataByteSize;
|
||||||
|
|
||||||
if (self->stopping == YES || [outputController shouldContinue] == NO ||
|
if (self->stopping == YES || [outputController shouldContinue] == NO)
|
||||||
([[outputController buffer] isEmpty] && ![outputController chainQueueHasTracks]))
|
|
||||||
{
|
{
|
||||||
// Chain is dead, fill out the serial number pointer forever with silence
|
// Chain is dead, fill out the serial number pointer forever with silence
|
||||||
memset(readPointer, 0, amountToRead);
|
memset(readPointer, 0, amountToRead);
|
||||||
|
@ -439,6 +445,14 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ([[outputController buffer] isEmpty] && ![outputController chainQueueHasTracks])
|
||||||
|
{
|
||||||
|
// Hit end of last track, pad with silence until queue event stops us
|
||||||
|
memset(readPointer, 0, amountToRead);
|
||||||
|
atomic_fetch_add(bytesRendered, amountToRead);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void * readPtr;
|
void * readPtr;
|
||||||
int toRead = [[outputController buffer] lengthAvailableToReadReturningPointer:&readPtr];
|
int toRead = [[outputController buffer] lengthAvailableToReadReturningPointer:&readPtr];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue