Fix audio crashing after some time.

This commit is contained in:
Luke Curley 2023-05-22 14:09:11 -07:00
parent 4132d8db4d
commit 58a1aa85ac
1 changed files with 3 additions and 7 deletions

View File

@ -60,12 +60,6 @@ export class Ring {
} }
} }
// capacity = 1024
// read = 2048
// write = 3072
// startIndex = 0
// readIndex = 0
let startIndex = startPos % this.capacity; let startIndex = startPos % this.capacity;
let endIndex = endPos % this.capacity; let endIndex = endPos % this.capacity;
@ -90,7 +84,9 @@ export class Ring {
frameCount: first.length, 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, { frame.copyTo(second, {
planeIndex: i, planeIndex: i,
frameOffset: first.length, frameOffset: first.length,