Skip to content

Commit b5d2135

Browse files
petterreinholdtsenPetter Reinholdtsen
and
Petter Reinholdtsen
authored
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 <[email protected]>
1 parent 17addf7 commit b5d2135

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

examples/stream/stream.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,11 @@ int main(int argc, char ** argv) {
244244

245245
if (!use_vad) {
246246
while (true) {
247+
// handle Ctrl + C
248+
is_running = sdl_poll_events();
249+
if (!is_running) {
250+
break;
251+
}
247252
audio.get(params.step_ms, pcmf32_new);
248253

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

0 commit comments

Comments
 (0)