From: Georgi Gerganov Date: Sun, 2 Oct 2022 17:11:17 +0000 (+0300) Subject: ref #10 : handle Ctrl+C in "stream" app X-Git-Tag: upstream/1.7.4~2004 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=be8ba034f6d8fbb4a3ab9774ae69cead29ad2421;p=pkg%2Fggml%2Fsources%2Fwhisper.cpp ref #10 : handle Ctrl+C in "stream" app --- diff --git a/stream.cpp b/stream.cpp index 918c5acc..52c4adf7 100644 --- a/stream.cpp +++ b/stream.cpp @@ -2252,8 +2252,22 @@ int main(int argc, char ** argv) { SDL_PauseAudioDevice(g_dev_id_in, 0); + bool is_running = true; + // main audio loop - while (true) { + while (is_running) { + // process SDL events: + SDL_Event event; + while (SDL_PollEvent(&event)) { + switch (event.type) { + case SDL_QUIT: + is_running = false; + break; + default: + break; + } + } + // process 3 seconds of new audio while ((int) SDL_GetQueuedAudioSize(g_dev_id_in) < 3*SAMPLE_RATE*sizeof(float)) { SDL_Delay(1);