From 2e57bc4a7cba4708b23cb80477fbc0f5f909f06c Mon Sep 17 00:00:00 2001 From: Petter Reinholdtsen Date: Sun, 16 Feb 2025 13:40:51 +0100 Subject: [PATCH] Adjusted stream example to stop on ^C when no audio is received. Add check for ctrl-c in potentially endless loop while calling audio.get() to receive sound. --- examples/stream/stream.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/examples/stream/stream.cpp b/examples/stream/stream.cpp index 833c240edd7..19d421387f8 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) {