Skip to content

Commit bc67d74

Browse files
committed
Simplified test further (printf the result)
1 parent 522a422 commit bc67d74

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

test/webaudio/audio_worklet_tone_generator.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include <emscripten/webaudio.h>
22
#include <emscripten/em_math.h>
33

4+
#include <stdio.h>
5+
46
// This program tests that sharing the WebAssembly Memory works between the
57
// audio generator thread and the main browser UI thread. Two sliders,
68
// frequency and volume, can be adjusted on the HTML page, and the audio thread
@@ -68,9 +70,6 @@ bool observe_test_end(double time, void *userData) {
6870
void AudioWorkletProcessorCreated(EMSCRIPTEN_WEBAUDIO_T audioContext, bool success, void *userData) {
6971
if (!success) return;
7072

71-
// Get the buffer's quantum size, we'll report this later
72-
int quantumSize = emscripten_audio_context_quantum_size(audioContext);
73-
7473
// Specify the input and output node configurations for the Wasm Audio
7574
// Worklet. A simple setup with single mono output channel here, and no
7675
// inputs.
@@ -101,12 +100,7 @@ void AudioWorkletProcessorCreated(EMSCRIPTEN_WEBAUDIO_T audioContext, bool succe
101100
audioContext.suspend();
102101
}
103102
};
104-
105-
// Report the buffer size out of interest
106-
let quantumText = document.createElement('p');
107-
quantumText.innerHTML += `(Buffer quantum size: ${$1})`;
108-
document.body.appendChild(quantumText);
109-
}, audioContext, quantumSize);
103+
}, audioContext);
110104

111105
#ifdef REPORT_RESULT
112106
emscripten_set_timeout_loop(observe_test_end, 10, 0);
@@ -156,6 +150,12 @@ int main() {
156150

157151
EMSCRIPTEN_WEBAUDIO_T context = emscripten_create_audio_context(&attrs);
158152

153+
// Get the context's quantum size. Once the audio API allows this to be user
154+
// defined or exposes the hardware's own value, this will be needed to
155+
// determine the worklet stack size.
156+
int quantumSize = emscripten_audio_context_quantum_size(context);
157+
printf("Context quantum size: %d\n", quantumSize);
158+
159159
// and kick off Audio Worklet scope initialization, which shares the Wasm
160160
// Module and Memory to the AudioWorklet scope and initializes its stack.
161161
emscripten_start_wasm_audio_worklet_thread_async(context, wasmAudioWorkletStack, sizeof(wasmAudioWorkletStack), WebAudioWorkletThreadInitialized, 0);

0 commit comments

Comments
 (0)