From 0a33ed7a2b936dcc8711ef09c47642207a6a30c5 Mon Sep 17 00:00:00 2001 From: Sylvain Date: Wed, 12 Apr 2023 11:42:27 +0200 Subject: [PATCH] testaudiocapture: let main exit normally --- test/testaudiocapture.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/test/testaudiocapture.c b/test/testaudiocapture.c index f251defc5..3272f77d2 100644 --- a/test/testaudiocapture.c +++ b/test/testaudiocapture.c @@ -25,6 +25,7 @@ static SDL_Renderer *renderer = NULL; static SDL_AudioSpec spec; static SDL_AudioDeviceID devid_in = 0; static SDL_AudioDeviceID devid_out = 0; +static int done = 0; static void loop(void) { @@ -72,7 +73,9 @@ static void loop(void) #ifdef __EMSCRIPTEN__ emscripten_cancel_main_loop(); #endif - exit(0); + /* Let 'main()' return normally */ + done = 1; + return; } /* 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__ emscripten_set_main_loop(loop, 0, 1); #else - while (1) { + while (!done) { loop(); - SDL_Delay(16); + if (!done) { + SDL_Delay(16); + } } #endif /* SDL_DestroyRenderer(renderer); */