Fix SDL_emscriptenaudio.c under wasm64

Verified locally by running `browser64.test_sdl2_mixer_wav` in
emscripten.
This commit is contained in:
Sam Clegg
2025-02-18 12:25:26 -08:00
committed by Sam Lantinga
parent 5330041ea9
commit aa00738a21

View File

@@ -310,7 +310,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
if ((SDL2 === undefined) || (SDL2.capture === undefined)) { return; } if ((SDL2 === undefined) || (SDL2.capture === undefined)) { return; }
audioProcessingEvent.outputBuffer.getChannelData(0).fill(0.0); audioProcessingEvent.outputBuffer.getChannelData(0).fill(0.0);
SDL2.capture.currentCaptureBuffer = audioProcessingEvent.inputBuffer; SDL2.capture.currentCaptureBuffer = audioProcessingEvent.inputBuffer;
dynCall('vi', $2, [$3]); dynCall('vp', $2, [$3]);
}; };
SDL2.capture.mediaStreamNode.connect(SDL2.capture.scriptProcessorNode); SDL2.capture.mediaStreamNode.connect(SDL2.capture.scriptProcessorNode);
SDL2.capture.scriptProcessorNode.connect(SDL2.audioContext.destination); SDL2.capture.scriptProcessorNode.connect(SDL2.audioContext.destination);
@@ -326,7 +326,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
SDL2.capture.silenceBuffer.getChannelData(0).fill(0.0); SDL2.capture.silenceBuffer.getChannelData(0).fill(0.0);
var silence_callback = function() { var silence_callback = function() {
SDL2.capture.currentCaptureBuffer = SDL2.capture.silenceBuffer; SDL2.capture.currentCaptureBuffer = SDL2.capture.silenceBuffer;
dynCall('vi', $2, [$3]); dynCall('vp', $2, [$3]);
}; };
SDL2.capture.silenceTimer = setInterval(silence_callback, ($1 / SDL2.audioContext.sampleRate) * 1000); SDL2.capture.silenceTimer = setInterval(silence_callback, ($1 / SDL2.audioContext.sampleRate) * 1000);
@@ -351,7 +351,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
SDL2.audio.silenceBuffer = undefined; SDL2.audio.silenceBuffer = undefined;
} }
SDL2.audio.currentOutputBuffer = e['outputBuffer']; SDL2.audio.currentOutputBuffer = e['outputBuffer'];
dynCall('vi', $2, [$3]); dynCall('vp', $2, [$3]);
}; };
SDL2.audio.scriptProcessorNode['connect'](SDL2.audioContext['destination']); SDL2.audio.scriptProcessorNode['connect'](SDL2.audioContext['destination']);
@@ -369,7 +369,7 @@ static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
// the buffer that gets filled here just gets ignored, so the app can make progress // the buffer that gets filled here just gets ignored, so the app can make progress
// and/or avoid flooding audio queues until we can actually play audio. // and/or avoid flooding audio queues until we can actually play audio.
SDL2.audio.currentOutputBuffer = SDL2.audio.silenceBuffer; SDL2.audio.currentOutputBuffer = SDL2.audio.silenceBuffer;
dynCall('vi', $2, [$3]); dynCall('vp', $2, [$3]);
SDL2.audio.currentOutputBuffer = undefined; SDL2.audio.currentOutputBuffer = undefined;
}; };