From 58a1aa85acc69e8feaea84f94925f9c3554a435f Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Mon, 22 May 2023 14:09:11 -0700 Subject: [PATCH] Fix audio crashing after some time. --- web/src/player/ring.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/web/src/player/ring.ts b/web/src/player/ring.ts index 4b1b7ae..2483692 100644 --- a/web/src/player/ring.ts +++ b/web/src/player/ring.ts @@ -60,12 +60,6 @@ export class Ring { } } - // capacity = 1024 - // read = 2048 - // write = 3072 - // startIndex = 0 - // readIndex = 0 - let startIndex = startPos % this.capacity; let endIndex = endPos % this.capacity; @@ -90,7 +84,9 @@ export class Ring { frameCount: first.length, }) - if (second.length > 0) { + // We need this conditional when startIndex == 0 and endIndex == 0 + // When capacity=4410 and frameCount=1024, this was happening 52s into the audio. + if (second.length) { frame.copyTo(second, { planeIndex: i, frameOffset: first.length,