From d1b519d59d9541d2e362c4521f2a3c587400c3b5 Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Wed, 12 Jan 2022 23:15:23 -0800 Subject: [PATCH] Cog Audio: Only declare end of stream on read when previous node has declared end of stream and the buffer has actually run empty. This prevents the case where the buffer may terminate early due to the read pointer hitting the end of the ring buffer and wrapping. --- Audio/Chain/Node.m | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Audio/Chain/Node.m b/Audio/Chain/Node.m index 8e9453678..8b2efb99d 100644 --- a/Audio/Chain/Node.m +++ b/Audio/Chain/Node.m @@ -96,17 +96,16 @@ void *readPtr; int amountToCopy; int availInput; + + if ([[previousNode buffer] isEmpty] && [previousNode endOfStream] == YES) + { + endOfStream = YES; + return 0; + } [readLock lock]; availInput = [[previousNode buffer] lengthAvailableToReadReturningPointer:&readPtr]; - if (availInput < amount && [previousNode endOfStream] == YES) - { -// [previousNode release]; - //If it is the outputNode, [soundController newInputChain]; - //else - endOfStream = YES; - } /* if (availInput <= 0) { DLog(@"BUFFER RAN DRY!"); }