Skip to content

Commit

Permalink
ref #10 : handle Ctrl+C in "stream" app
Browse files Browse the repository at this point in the history
  • Loading branch information
ggerganov committed Oct 2, 2022
1 parent d71e567 commit be8ba03
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2252,8 +2252,22 @@ int main(int argc, char ** argv) {

SDL_PauseAudioDevice(g_dev_id_in, 0);

bool is_running = true;

// main audio loop
while (true) {
while (is_running) {
// process SDL events:
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_QUIT:
is_running = false;
break;
default:
break;
}
}

// process 3 seconds of new audio
while ((int) SDL_GetQueuedAudioSize(g_dev_id_in) < 3*SAMPLE_RATE*sizeof(float)) {
SDL_Delay(1);
Expand Down

0 comments on commit be8ba03

Please sign in to comment.