From edf8657d198867cb60d636d45c921b69cee41a35 Mon Sep 17 00:00:00 2001 From: Arnaud Blanchard <arnaud.blanchard@ensea.fr> Date: Thu, 3 Oct 2019 22:31:57 +0200 Subject: [PATCH] Add a function 'void blc_loop_wait_stop(); ' used to wait for the main thread of the blc_loop to stop. (used by coreaudio) --- include/blc_command.h | 5 +++++ src/blc_loop.cpp | 6 +++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/blc_command.h b/include/blc_command.h index 9a51760..37fca62 100644 --- a/include/blc_command.h +++ b/include/blc_command.h @@ -126,6 +126,11 @@ void blc_command_loop_init(long loop_period); int blc_command_loop_start(); void blc_command_loop_end(); + +/** Wait that the loop_thread launched by 'blc_command_loop_init' listining on keyboard stops ( i.e. 'quitting has been requested ).*/ +void blc_loop_wait_stop(); + + /** Stop a textual program * - Send a quitting message with the name of the app on stderr. * - Send 'q' and flush on stdout if it is a piped output diff --git a/src/blc_loop.cpp b/src/blc_loop.cpp index 6716e60..d3d8afe 100644 --- a/src/blc_loop.cpp +++ b/src/blc_loop.cpp @@ -36,7 +36,6 @@ static struct timeval step_timer, profile_timer; static sem_t *blocking_semaphore=NULL; - type_blc_status blc_status=BLC_RUN; void blc_fprint_stats(FILE *file){ @@ -291,3 +290,8 @@ void blc_command_loop_end(){ intermediate_iteration++; blc_loop_iteration++; } + + +void blc_loop_wait_stop(){ + pthread_join(loop_thread, nullptr); +} -- GitLab