Skip to content

Commit 8b52179

Browse files
committed
Button can only be clicked once
1 parent c9903bd commit 8b52179

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

test/webaudio/audioworklet_emscripten_locks.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,16 @@ bool mainLoop(double time, void* data) {
158158
}
159159

160160
EMSCRIPTEN_KEEPALIVE void startTest() {
161-
startTime = emscripten_get_now();
162-
if (emscripten_audio_context_state(context) != AUDIO_CONTEXT_STATE_RUNNING) {
163-
emscripten_resume_audio_context_sync(context);
161+
if (whichTest == TEST_NOT_STARTED) {
162+
startTime = emscripten_get_now();
163+
if (emscripten_audio_context_state(context) != AUDIO_CONTEXT_STATE_RUNNING) {
164+
emscripten_resume_audio_context_sync(context);
165+
}
166+
howManyMain = MAINLOOP_RUNS;
167+
howManyProc = PROCESS_RUNS;
168+
} else {
169+
emscripten_out("Reload page to re-run");
164170
}
165-
howManyMain = MAINLOOP_RUNS;
166-
howManyProc = PROCESS_RUNS;
167171
}
168172

169173
// HTML button to manually run the test
@@ -172,9 +176,7 @@ EM_JS(void, addButton, (), {
172176
button.appendChild(document.createTextNode("Start Test"));
173177
document.body.appendChild(button);
174178
document.onclick = () => {
175-
if (globalThis._startTest) {
176-
_startTest();
177-
}
179+
_startTest();
178180
};
179181
});
180182

0 commit comments

Comments
 (0)