petterreinholdtsen Petter Reinholdtsen commited on
Commit
45399ad
·
unverified ·
1 Parent(s): 7926873

stream : stop on ^C when no audio is received (#2822)

Browse files

Add check for ctrl-c in potentially endless loop while calling audio.get()
to receive sound.

Co-authored-by: Petter Reinholdtsen <[email protected]>

Files changed (1) hide show
  1. examples/stream/stream.cpp +5 -0
examples/stream/stream.cpp CHANGED
@@ -244,6 +244,11 @@ int main(int argc, char ** argv) {
244
 
245
  if (!use_vad) {
246
  while (true) {
 
 
 
 
 
247
  audio.get(params.step_ms, pcmf32_new);
248
 
249
  if ((int) pcmf32_new.size() > 2*n_samples_step) {
 
244
 
245
  if (!use_vad) {
246
  while (true) {
247
+ // handle Ctrl + C
248
+ is_running = sdl_poll_events();
249
+ if (!is_running) {
250
+ break;
251
+ }
252
  audio.get(params.step_ms, pcmf32_new);
253
 
254
  if ((int) pcmf32_new.size() > 2*n_samples_step) {