Spaces:
Sleeping
Sleeping
ref #10 : handle Ctrl+C in "stream" app
Browse files- stream.cpp +15 -1
stream.cpp
CHANGED
|
@@ -2252,8 +2252,22 @@ int main(int argc, char ** argv) {
|
|
| 2252 |
|
| 2253 |
SDL_PauseAudioDevice(g_dev_id_in, 0);
|
| 2254 |
|
|
|
|
|
|
|
| 2255 |
// main audio loop
|
| 2256 |
-
while (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2257 |
// process 3 seconds of new audio
|
| 2258 |
while ((int) SDL_GetQueuedAudioSize(g_dev_id_in) < 3*SAMPLE_RATE*sizeof(float)) {
|
| 2259 |
SDL_Delay(1);
|
|
|
|
| 2252 |
|
| 2253 |
SDL_PauseAudioDevice(g_dev_id_in, 0);
|
| 2254 |
|
| 2255 |
+
bool is_running = true;
|
| 2256 |
+
|
| 2257 |
// main audio loop
|
| 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 |
+
|
| 2271 |
// process 3 seconds of new audio
|
| 2272 |
while ((int) SDL_GetQueuedAudioSize(g_dev_id_in) < 3*SAMPLE_RATE*sizeof(float)) {
|
| 2273 |
SDL_Delay(1);
|