diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-09-15 12:54:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-15 12:54:51 +0200 |
commit | f18a6f2fd01d1c81c7dac670c9e9321c4470eaeb (patch) | |
tree | 5c6fc350c5f4df77243aceade8d4d62209977d82 | |
parent | 13d2928490d07bcf7cfc04c8e8b49c0924b84014 (diff) | |
parent | ba08f39e47f12c6910388f41367305c93eaa06e4 (diff) |
Merge pull request #52696 from Faless/js/4.x_worklet_rb_bug
-rw-r--r-- | platform/javascript/js/libs/audio.worklet.js | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/platform/javascript/js/libs/audio.worklet.js b/platform/javascript/js/libs/audio.worklet.js index 866f845139..df475ba52d 100644 --- a/platform/javascript/js/libs/audio.worklet.js +++ b/platform/javascript/js/libs/audio.worklet.js @@ -66,17 +66,17 @@ class RingBuffer { const mw = this.buffer.length - this.wpos; if (mw >= to_write) { this.buffer.set(p_buffer, this.wpos); + this.wpos += to_write; + if (mw === to_write) { + this.wpos = 0; + } } else { - const high = p_buffer.subarray(0, to_write - mw); - const low = p_buffer.subarray(to_write - mw); + const high = p_buffer.subarray(0, mw); + const low = p_buffer.subarray(mw); this.buffer.set(high, this.wpos); this.buffer.set(low); + this.wpos = low.length; } - let diff = to_write; - if (this.wpos + diff >= this.buffer.length) { - diff -= this.buffer.length; - } - this.wpos += diff; Atomics.add(this.avail, 0, to_write); Atomics.notify(this.avail, 0); } |