src/audio/emscripten/SDL_emscriptenaudio.c
changeset 9344 83f4ab8fb0b8
parent 9291 02b47b8164da
child 9394 bb28e5281770
--- a/src/audio/emscripten/SDL_emscriptenaudio.c	Sat Feb 14 00:13:00 2015 +0100
+++ b/src/audio/emscripten/SDL_emscriptenaudio.c	Sat Feb 14 00:16:27 2015 +0100
@@ -157,6 +157,7 @@
     SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format);
     int i;
     float f;
+    int result;
 
     while ((!valid_format) && (test_format)) {
         switch (test_format) {
@@ -185,7 +186,7 @@
     /* based on parts of library_sdl.js */
 
     /* create context (TODO: this puts stuff in the global namespace...)*/
-    EM_ASM({
+    result = EM_ASM_INT_V({
         if(typeof(SDL2) === 'undefined')
             SDL2 = {};
 
@@ -198,10 +199,14 @@
             } else if (typeof(webkitAudioContext) !== 'undefined') {
                 SDL2.audioContext = new webkitAudioContext();
             } else {
-                throw 'Web Audio API is not available!';
+                return -1;
             }
         }
+        return 0;
     });
+    if (result < 0) {
+        return SDL_SetError("Web Audio API is not available!");
+    }
 
     /* limit to native freq */
     int sampleRate = EM_ASM_INT_V({