Skip to content

Commit c708075

Browse files
author
Petter Reinholdtsen
committed
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.
1 parent d682e15 commit c708075

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

examples/stream/stream.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ int main(int argc, char ** argv) {
241241

242242
if (!use_vad) {
243243
while (true) {
244+
// handle Ctrl + C
245+
is_running = sdl_poll_events();
246+
if (!is_running) {
247+
break;
248+
}
244249
audio.get(params.step_ms, pcmf32_new);
245250

246251
if ((int) pcmf32_new.size() > 2*n_samples_step) {

0 commit comments

Comments
 (0)