From 95f4312fb0a6aca0786671f151b646ca124a7f75 Mon Sep 17 00:00:00 2001 From: anton-kl Date: Fri, 14 Apr 2017 15:30:54 +0200 Subject: [PATCH] Fixed onaudioprocess finalizing There is an edge case, when audio callback is still called after closing audio device, which leads to crash because audio device doesn't exists anymore. In this function there is a proper scriptProcessorNode finalizing code, but only for "if capture is enabled" branch, which is placed above. So the fix is to use the same method for clearing onaudioprocess as in the code above. --- src/audio/emscripten/SDL_emscriptenaudio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/audio/emscripten/SDL_emscriptenaudio.c b/src/audio/emscripten/SDL_emscriptenaudio.c index 839d445ee6..f343696ba9 100644 --- a/src/audio/emscripten/SDL_emscriptenaudio.c +++ b/src/audio/emscripten/SDL_emscriptenaudio.c @@ -225,6 +225,7 @@ EMSCRIPTENAUDIO_CloseDevice(_THIS) SDL2.capture = undefined; } else { if (SDL2.audio.scriptProcessorNode != undefined) { + SDL2.audio.scriptProcessorNode.onaudioprocess = function(audioProcessingEvent) {}; SDL2.audio.scriptProcessorNode.disconnect(); SDL2.audio.scriptProcessorNode = undefined; }