Spaces:
Running
Running
petterreinholdtsen
Petter Reinholdtsen
commited on
stream : stop on ^C when no audio is received (#2822)
Browse filesAdd check for ctrl-c in potentially endless loop while calling audio.get()
to receive sound.
Co-authored-by: Petter Reinholdtsen <[email protected]>
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) {
|