From 20be1d634b71db251af0c2ba096cbc9cdaec15b7 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Wed, 15 Jul 2020 09:13:03 -0700 Subject: [PATCH] emscripten: Automatically resume audio contexts This uses the mechanism added in emscripten-core/emscripten#10843 which was applied to SDL1 and OpenAL. This adds the same for SDL2. This also reverts commit 865eaddffed50dbd13e6564c3f73902472cf74e8 which did something similar, but the new mechanism is more effective. --- src/audio/emscripten/SDL_emscriptenaudio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/audio/emscripten/SDL_emscriptenaudio.c b/src/audio/emscripten/SDL_emscriptenaudio.c index a0f04324c..5bcb48b37 100644 --- a/src/audio/emscripten/SDL_emscriptenaudio.c +++ b/src/audio/emscripten/SDL_emscriptenaudio.c @@ -215,6 +215,9 @@ EMSCRIPTENAUDIO_OpenDevice(_THIS, void *handle, const char *devname, int iscaptu } else if (typeof(webkitAudioContext) !== 'undefined') { SDL2.audioContext = new webkitAudioContext(); } + if (SDL2.audioContext) { + autoResumeAudioContext(SDL2.audioContext); + } } return SDL2.audioContext === undefined ? -1 : 0; }, iscapture);