Skip to content

Commit 28d43cc

Browse files
committed
When feeding and updating queued audio buffers in OpenAL, the buffers might have been created with different OpenAL audio contexts, so audio update code should not rely on a single active AL context, but update each source with the audio context that was used to create that audio source. Also fixes the issue where code un-makecurrents OpenAL audio context in a thread when there are audio sources playing.
1 parent 800c110 commit 28d43cc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/library_openal.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ var LibraryOpenAL = {
5252
return;
5353
}
5454

55-
var currentTime = AL.currentContext.ctx.currentTime;
55+
var currentTime = src.context.ctx.currentTime;
5656
var startTime = src.bufferPosition;
5757

5858
for (var i = src.buffersPlayed; i < src.queue.length; i++) {
@@ -83,7 +83,7 @@ var LibraryOpenAL = {
8383
// If the start offset is negative, we need to offset the actual buffer.
8484
var offset = Math.abs(Math.min(startOffset, 0));
8585

86-
entry.src = AL.currentContext.ctx.createBufferSource();
86+
entry.src = src.context.ctx.createBufferSource();
8787
entry.src.buffer = entry.buffer;
8888
entry.src.connect(src.gain);
8989
if (src.playbackRate != 1.0) entry.src.playbackRate.value = src.playbackRate;
@@ -372,6 +372,7 @@ var LibraryOpenAL = {
372372
var gain = AL.currentContext.ctx.createGain();
373373
gain.connect(AL.currentContext.gain);
374374
AL.currentContext.src[AL.newSrcId] = {
375+
context: AL.currentContext,
375376
state: 0x1011 /* AL_INITIAL */,
376377
queue: [],
377378
loop: false,

0 commit comments

Comments
 (0)