emscripten audio: check for an "undefined" object, remove some console.log().
authorRyan C. Gordon <icculus@icculus.org>
Fri, 12 Aug 2016 00:03:58 -0400
changeset 102831b8594db77f1
parent 10282 8bd5eb9d96c7
child 10284 c09f06c4e8c8
emscripten audio: check for an "undefined" object, remove some console.log().
src/audio/emscripten/SDL_emscriptenaudio.c
     1.1 --- a/src/audio/emscripten/SDL_emscriptenaudio.c	Thu Aug 11 22:26:58 2016 -0400
     1.2 +++ b/src/audio/emscripten/SDL_emscriptenaudio.c	Fri Aug 12 00:03:58 2016 -0400
     1.3 @@ -330,8 +330,11 @@
     1.4  
     1.5          EM_ASM_({
     1.6              var have_microphone = function(stream) {
     1.7 -                clearTimeout(SDL2.capture.silenceTimer);
     1.8 -                SDL2.capture.silenceTimer = undefined;
     1.9 +                //console.log('SDL audio capture: we have a microphone! Replacing silence callback.');
    1.10 +                if (SDL2.capture.silenceTimer !== undefined) {
    1.11 +                    clearTimeout(SDL2.capture.silenceTimer);
    1.12 +                    SDL2.capture.silenceTimer = undefined;
    1.13 +                }
    1.14                  SDL2.capture.mediaStreamNode = SDL2.audioContext.createMediaStreamSource(stream);
    1.15                  SDL2.capture.scriptProcessorNode = SDL2.audioContext.createScriptProcessor($1, $0, 1);
    1.16                  SDL2.capture.scriptProcessorNode.onaudioprocess = function(audioProcessingEvent) {
    1.17 @@ -344,13 +347,12 @@
    1.18              };
    1.19  
    1.20              var no_microphone = function(error) {
    1.21 -                console.log('we DO NOT have a microphone! (' + error.name + ')...leaving silence callback running.');
    1.22 +                //console.log('SDL audio capture: we DO NOT have a microphone! (' + error.name + ')...leaving silence callback running.');
    1.23              };
    1.24  
    1.25              /* we write silence to the audio callback until the microphone is available (user approves use, etc). */
    1.26              SDL2.capture.silenceBuffer = SDL2.audioContext.createBuffer($0, $1, SDL2.audioContext.sampleRate);
    1.27              SDL2.capture.silenceBuffer.getChannelData(0).fill(0.0);
    1.28 -
    1.29              var silence_callback = function() {
    1.30                  SDL2.capture.currentCaptureBuffer = SDL2.capture.silenceBuffer;
    1.31                  Runtime.dynCall('vi', $2, [$3]);