Skip to content

Commit

Permalink
Simplified test further (printf the result)
Browse files Browse the repository at this point in the history
  • Loading branch information
cwoffenden committed Oct 8, 2024
1 parent 522a422 commit bc67d74
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions test/webaudio/audio_worklet_tone_generator.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <emscripten/webaudio.h>
#include <emscripten/em_math.h>

#include <stdio.h>

// This program tests that sharing the WebAssembly Memory works between the
// audio generator thread and the main browser UI thread. Two sliders,
// frequency and volume, can be adjusted on the HTML page, and the audio thread
Expand Down Expand Up @@ -68,9 +70,6 @@ bool observe_test_end(double time, void *userData) {
void AudioWorkletProcessorCreated(EMSCRIPTEN_WEBAUDIO_T audioContext, bool success, void *userData) {
if (!success) return;

// Get the buffer's quantum size, we'll report this later
int quantumSize = emscripten_audio_context_quantum_size(audioContext);

// Specify the input and output node configurations for the Wasm Audio
// Worklet. A simple setup with single mono output channel here, and no
// inputs.
Expand Down Expand Up @@ -101,12 +100,7 @@ void AudioWorkletProcessorCreated(EMSCRIPTEN_WEBAUDIO_T audioContext, bool succe
audioContext.suspend();
}
};

// Report the buffer size out of interest
let quantumText = document.createElement('p');
quantumText.innerHTML += `(Buffer quantum size: ${$1})`;
document.body.appendChild(quantumText);
}, audioContext, quantumSize);
}, audioContext);

#ifdef REPORT_RESULT
emscripten_set_timeout_loop(observe_test_end, 10, 0);
Expand Down Expand Up @@ -156,6 +150,12 @@ int main() {

EMSCRIPTEN_WEBAUDIO_T context = emscripten_create_audio_context(&attrs);

// Get the context's quantum size. Once the audio API allows this to be user
// defined or exposes the hardware's own value, this will be needed to
// determine the worklet stack size.
int quantumSize = emscripten_audio_context_quantum_size(context);
printf("Context quantum size: %d\n", quantumSize);

// and kick off Audio Worklet scope initialization, which shares the Wasm
// Module and Memory to the AudioWorklet scope and initializes its stack.
emscripten_start_wasm_audio_worklet_thread_async(context, wasmAudioWorkletStack, sizeof(wasmAudioWorkletStack), WebAudioWorkletThreadInitialized, 0);
Expand Down

0 comments on commit bc67d74

Please sign in to comment.