From 99bc91a3c939e07f2d754a67dce60a55d509b3c1 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Sun, 12 Jul 2020 10:56:36 -0700 Subject: get_frame: insert brief sleep when paused rmdGetFrame() can't just block on pause_cond because it services the event loop, which may be the very thing responsible for unpausing when not triggered by an external signal. The existing code handles this correctly but it spins on polling the paused flag and running the event loop when paused. This commit just adds a short delay to that cycle so the rmdGetFrame thread doesn't pointlessly burn CPU while paused. --- src/rmd_get_frame.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/rmd_get_frame.c b/src/rmd_get_frame.c index 8d8b8d8..3f5c084 100644 --- a/src/rmd_get_frame.c +++ b/src/rmd_get_frame.c @@ -45,6 +45,7 @@ #include #include #include +#include /* clip_event_area dejavu */ @@ -345,8 +346,16 @@ void *rmdGetFrame(ProgData *pdata) { //events (if not full_shots) rmdEventLoop(pdata); - if (pdata->paused) + if (pdata->paused) { + /* This is a bit janky, but there's need to service the event loop + * when paused, so instead of blocking on pause_cond, a short sleep + * is performed. + * Since the timer keeps running currently when paused, the above + * cond_wait() will never prevent us from reaching here. + */ + nanosleep(&(struct timespec){ .tv_nsec = 50000000 }, NULL); continue; + } //switch back and front buffers (full_shots only) if (d_buff) -- cgit v1.2.3