aboutsummaryrefslogtreecommitdiff
path: root/src/library_sdl.js
diff options
context:
space:
mode:
authorJukka Jylänki <jujjyl@gmail.com>2013-06-16 18:34:48 +0300
committerAlon Zakai <alonzakai@gmail.com>2013-09-24 16:56:44 -0700
commit9447edeb28ff332ca0a9148db66bdf3f2c363e1f (patch)
treeea3d6853bb98fbf9495231ca2b035184e1bd2320 /src/library_sdl.js
parent257d5f4d0b4932817b2bbf9071134346ed7f6392 (diff)
Explicitly disconnect generated audio buffers with Web Audio API to guarantee no resources will be leaked. (not sure if this is necessary, but it uncovered a timing bug, and doesn't hurt to be safe)
Diffstat (limited to 'src/library_sdl.js')
-rw-r--r--src/library_sdl.js3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/library_sdl.js b/src/library_sdl.js
index 3851caaf..e8c4b6b8 100644
--- a/src/library_sdl.js
+++ b/src/library_sdl.js
@@ -1578,6 +1578,9 @@ var LibrarySDL = {
}
// Allocate new sound buffer to be played.
var source = SDL.audioContext['createBufferSource']();
+ if (SDL.audio.soundSource[SDL.audio.nextSoundSource]) {
+ SDL.audio.soundSource[SDL.audio.nextSoundSource]['disconnect']();
+ }
SDL.audio.soundSource[SDL.audio.nextSoundSource] = source;
source.buffer = SDL.audioContext['createBuffer'](SDL.audio.channels,sizeSamplesPerChannel,SDL.audio.freq);
SDL.audio.soundSource[SDL.audio.nextSoundSource]['connect'](SDL.audioContext['destination']);