testaudiocapture: let main exit normally

This commit is contained in:
Sylvain
2023-04-12 11:42:27 +02:00
committed by Sylvain Becker
parent c101e719fd
commit 0a33ed7a2b

View File

@@ -25,6 +25,7 @@ static SDL_Renderer *renderer = NULL;
static SDL_AudioSpec spec; static SDL_AudioSpec spec;
static SDL_AudioDeviceID devid_in = 0; static SDL_AudioDeviceID devid_in = 0;
static SDL_AudioDeviceID devid_out = 0; static SDL_AudioDeviceID devid_out = 0;
static int done = 0;
static void loop(void) static void loop(void)
{ {
@@ -72,7 +73,9 @@ static void loop(void)
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
emscripten_cancel_main_loop(); emscripten_cancel_main_loop();
#endif #endif
exit(0); /* Let 'main()' return normally */
done = 1;
return;
} }
/* Note that it would be easier to just have a one-line function that /* Note that it would be easier to just have a one-line function that
@@ -187,9 +190,11 @@ int main(int argc, char **argv)
#ifdef __EMSCRIPTEN__ #ifdef __EMSCRIPTEN__
emscripten_set_main_loop(loop, 0, 1); emscripten_set_main_loop(loop, 0, 1);
#else #else
while (1) { while (!done) {
loop(); loop();
SDL_Delay(16); if (!done) {
SDL_Delay(16);
}
} }
#endif #endif
/* SDL_DestroyRenderer(renderer); */ /* SDL_DestroyRenderer(renderer); */