From b5d21359c11fc9d19f8efb7bdcb0688d6b643d58 Mon Sep 17 00:00:00 2001 From: petterreinholdtsen Date: Thu, 27 Feb 2025 07:59:51 +0100 Subject: [PATCH] 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 --- examples/stream/stream.cpp | 5 +++++ 1 file changed, 5 insertions(+) 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) {