Skip to content

Commit 9e63502

Browse files
committed
Revert back test (changes moved to emscripten-core#23695)
1 parent 9fd83f7 commit 9e63502

File tree

1 file changed

+11
-27
lines changed

1 file changed

+11
-27
lines changed

test/webaudio/audioworklet.c

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,16 @@
2222
begin to fire.
2323
*/
2424

25-
// TEST_AND_EXIT is defined when running in Emscripten test harness. You can
26-
// strip these out in your own project (otherwise playback will end quickly).
27-
#ifdef TEST_AND_EXIT
25+
// REPORT_RESULT is defined when running in Emscripten test harness. You can
26+
// strip these out in your own project.
27+
#ifdef REPORT_RESULT
2828
_Thread_local int testTlsVariable = 1;
2929
int lastTlsVariableValueInAudioThread = 1;
3030
#endif
3131

3232
// This function will be called for every fixed-size buffer of audio samples to be processed.
3333
bool ProcessAudio(int numInputs, const AudioSampleFrame *inputs, int numOutputs, AudioSampleFrame *outputs, int numParams, const AudioParamFrame *params, void *userData) {
34-
#ifdef TEST_AND_EXIT
35-
// Only running in the test harness, see main_thread_tls_access()
34+
#ifdef REPORT_RESULT
3635
assert(testTlsVariable == lastTlsVariableValueInAudioThread);
3736
++testTlsVariable;
3837
lastTlsVariableValueInAudioThread = testTlsVariable;
@@ -64,15 +63,14 @@ EM_JS(void, InitHtmlUi, (EMSCRIPTEN_WEBAUDIO_T audioContext), {
6463
};
6564
});
6665

67-
#ifdef TEST_AND_EXIT
66+
#ifdef REPORT_RESULT
6867
bool main_thread_tls_access(double time, void *userData) {
6968
// Try to mess the TLS variable on the main thread, with the expectation that
70-
// it should not change the TLS value on the AudioWorklet thread, asserted in
71-
// ProcessAudio().
69+
// it should not change the TLS value on the AudioWorklet thread.
7270
testTlsVariable = (int)time;
73-
// Exit to the test harness after enough calls to ProcessAudio()
7471
if (lastTlsVariableValueInAudioThread >= 100) {
75-
emscripten_force_exit(EXIT_SUCCESS);
72+
REPORT_RESULT(0);
73+
return false;
7674
}
7775
return true;
7876
}
@@ -81,11 +79,7 @@ bool main_thread_tls_access(double time, void *userData) {
8179
// This callback will fire after the Audio Worklet Processor has finished being
8280
// added to the Worklet global scope.
8381
void AudioWorkletProcessorCreated(EMSCRIPTEN_WEBAUDIO_T audioContext, bool success, void *userData) {
84-
if (!success) {
85-
emscripten_out("Stopped in AudioWorkletProcessorCreated");
86-
assert(0);
87-
return;
88-
}
82+
if (!success) return;
8983

9084
// Specify the input and output node configurations for the Wasm Audio
9185
// Worklet. A simple setup with single mono output channel here, and no
@@ -103,8 +97,7 @@ void AudioWorkletProcessorCreated(EMSCRIPTEN_WEBAUDIO_T audioContext, bool succe
10397
// Connect the audio worklet node to the graph.
10498
emscripten_audio_node_connect(wasmAudioWorklet, audioContext, 0, 0);
10599

106-
#ifdef TEST_AND_EXIT
107-
// Schedule this to exit after ProcessAudio() has been called 100 times
100+
#ifdef REPORT_RESULT
108101
emscripten_set_timeout_loop(main_thread_tls_access, 10, 0);
109102
#endif
110103

@@ -115,11 +108,7 @@ void AudioWorkletProcessorCreated(EMSCRIPTEN_WEBAUDIO_T audioContext, bool succe
115108
// AudioWorklet global scope, and is now ready to begin adding Audio Worklet
116109
// Processors.
117110
void WebAudioWorkletThreadInitialized(EMSCRIPTEN_WEBAUDIO_T audioContext, bool success, void *userData) {
118-
if (!success) {
119-
emscripten_out("Stopped in WebAudioWorkletThreadInitialized");
120-
assert(0);
121-
return;
122-
}
111+
if (!success) return;
123112

124113
WebAudioWorkletProcessorCreateOptions opts = {
125114
.name = "noise-generator",
@@ -143,9 +132,4 @@ int main() {
143132
// and kick off Audio Worklet scope initialization, which shares the Wasm
144133
// Module and Memory to the AudioWorklet scope and initializes its stack.
145134
emscripten_start_wasm_audio_worklet_thread_async(context, wasmAudioWorkletStack, sizeof(wasmAudioWorkletStack), WebAudioWorkletThreadInitialized, 0);
146-
147-
#ifdef TEST_AND_EXIT
148-
// We're in the test harness and exiting is via main_thread_tls_access()
149-
emscripten_exit_with_live_runtime();
150-
#endif
151135
}

0 commit comments

Comments
 (0)