From: petterreinholdtsen Date: Thu, 27 Feb 2025 06:59:51 +0000 (+0100) Subject: stream : stop on ^C when no audio is received (#2822) X-Git-Tag: upstream/1.7.4+203~45 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=b5d21359c11fc9d19f8efb7bdcb0688d6b643d58;p=pkg%2Fggml%2Fsources%2Fwhisper.cpp stream : stop on ^C when no audio is received (#2822) Add check for ctrl-c in potentially endless loop while calling audio.get() to receive sound. Co-authored-by: Petter Reinholdtsen --- diff --git a/examples/stream/stream.cpp b/examples/stream/stream.cpp index 833c240e..19d42138 100644 --- a/examples/stream/stream.cpp +++ b/examples/stream/stream.cpp @@ -244,6 +244,11 @@ int main(int argc, char ** argv) { if (!use_vad) { while (true) { + // handle Ctrl + C + is_running = sdl_poll_events(); + if (!is_running) { + break; + } audio.get(params.step_ms, pcmf32_new); if ((int) pcmf32_new.size() > 2*n_samples_step) {