Fix audio crashing after some time.

This commit is contained in:
Luke Curley 2023-05-22 13:49:02 -07:00
parent 3f6ea42380
commit 4132d8db4d
1 changed files with 14 additions and 5 deletions

View File

@ -60,6 +60,12 @@ export class Ring {
}
}
// capacity = 1024
// read = 2048
// write = 3072
// startIndex = 0
// readIndex = 0
let startIndex = startPos % this.capacity;
let endIndex = endPos % this.capacity;
@ -84,6 +90,7 @@ export class Ring {
frameCount: first.length,
})
if (second.length > 0) {
frame.copyTo(second, {
planeIndex: i,
frameOffset: first.length,
@ -91,6 +98,7 @@ export class Ring {
})
}
}
}
Atomics.store(this.state, STATE.WRITE_POS, endPos)
@ -142,6 +150,7 @@ export class Ring {
}
size() {
// TODO is this thread safe?
let readPos = Atomics.load(this.state, STATE.READ_POS)
let writePos = Atomics.load(this.state, STATE.WRITE_POS)