From 8c809818272b3979c5952b569d4a99bf24c6bf02 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Fri, 18 Oct 2013 05:33:38 -0700 Subject: [PATCH] Minor changes that may or may not have any impact on gaplessness --- Audio/Chain/InputNode.m | 15 +++++++++------ Audio/Chain/Node.m | 2 +- Audio/Chain/OutputNode.m | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Audio/Chain/InputNode.m b/Audio/Chain/InputNode.m index e40d7e031..c56118c58 100644 --- a/Audio/Chain/InputNode.m +++ b/Audio/Chain/InputNode.m @@ -134,9 +134,15 @@ if (amountInBuffer < CHUNK_SIZE) { int framesToRead = (CHUNK_SIZE - amountInBuffer)/bytesPerFrame; int framesRead = [decoder readAudio:((char *)inputBuffer) + amountInBuffer frames:framesToRead]; - amountInBuffer += (framesRead * bytesPerFrame); - if (framesRead <= 0) + if (framesRead > 0) + { + amountInBuffer += (framesRead * bytesPerFrame); + [self writeData:inputBuffer amount:amountInBuffer]; + amountInBuffer = 0; + } + + if (framesRead < framesToRead) { if (initialBufferFilled == NO) { [controller initialBufferFilled:self]; @@ -163,10 +169,7 @@ break; } } - - [self writeData:inputBuffer amount:amountInBuffer]; - amountInBuffer = 0; - } + } } if (shouldClose) diff --git a/Audio/Chain/Node.m b/Audio/Chain/Node.m index 2dc4951b9..bf5562e0c 100644 --- a/Audio/Chain/Node.m +++ b/Audio/Chain/Node.m @@ -105,7 +105,7 @@ [readLock lock]; availInput = [[previousNode buffer] lengthAvailableToReadReturningPointer:&readPtr]; - if (availInput <= amount && [previousNode endOfStream] == YES) + if (availInput < amount && [previousNode endOfStream] == YES) { // [previousNode release]; //If it is the outputNode, [soundController newInputChain]; diff --git a/Audio/Chain/OutputNode.m b/Audio/Chain/OutputNode.m index 006abeb81..b9f5fd11f 100644 --- a/Audio/Chain/OutputNode.m +++ b/Audio/Chain/OutputNode.m @@ -54,6 +54,8 @@ [self setPreviousNode:[[controller bufferChain] finalNode]]; n = [super readData:ptr amount:amount]; + amountPlayed += n; + if (endOfStream == YES) { amountPlayed = 0; @@ -64,8 +66,6 @@ DLog(@"Output Buffer dry!"); } */ - amountPlayed += n; - [pool release]; return n;