Fix audio crashing after some time.
This commit is contained in:
parent
3f6ea42380
commit
4132d8db4d
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue