Skip to content

Commit be8ba03

Browse files
committed
ref #10 : handle Ctrl+C in "stream" app
1 parent d71e567 commit be8ba03

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

stream.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2252,8 +2252,22 @@ int main(int argc, char ** argv) {
22522252

22532253
SDL_PauseAudioDevice(g_dev_id_in, 0);
22542254

2255+
bool is_running = true;
2256+
22552257
// main audio loop
2256-
while (true) {
2258+
while (is_running) {
2259+
// process SDL events:
2260+
SDL_Event event;
2261+
while (SDL_PollEvent(&event)) {
2262+
switch (event.type) {
2263+
case SDL_QUIT:
2264+
is_running = false;
2265+
break;
2266+
default:
2267+
break;
2268+
}
2269+
}
2270+
22572271
// process 3 seconds of new audio
22582272
while ((int) SDL_GetQueuedAudioSize(g_dev_id_in) < 3*SAMPLE_RATE*sizeof(float)) {
22592273
SDL_Delay(1);

0 commit comments

Comments
 (0)