diff options
author | Vito Caputo <vcaputo@pengaru.com> | 2020-07-14 18:49:21 -0700 |
---|---|---|
committer | Vito Caputo <vcaputo@pengaru.com> | 2020-07-14 18:49:21 -0700 |
commit | 79cc627a9acae89d05b4e0c213b97ad4c0aec619 (patch) | |
tree | 46a7cfeedcab2b79e0b81d8e5f7a651d6ead690a /src/rmd_timer.c | |
parent | 5ce6553ccf5502fc71d11d654c76bd1714cd36dd (diff) |
timer: don't advance time_frameno when paused
This requires a bit of adjustment in the get_frame time_cond wait
loop so it still services the event loop when woken without advance
At least now get_frame has no explicit pause code, but it does
require the timer keep firing while paused so it signals time_cond.
Diffstat (limited to 'src/rmd_timer.c')
-rw-r--r-- | src/rmd_timer.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/src/rmd_timer.c b/src/rmd_timer.c index f584bf2..a523166 100644 --- a/src/rmd_timer.c +++ b/src/rmd_timer.c @@ -113,14 +113,25 @@ void *rmdTimer(ProgData *pdata) { } } + /* When paused, stop advancing time_frameno, get_frame only progresses + * when time_frameno > capture_frameno. But get_frame needs to service + * the event loop even when paused, so still signal time_cond just with + * pdata->time_frameno frozen. get_frame will then handle time_cond + * wakeups where capture_frameno >= time_frameno as "poll events". + */ + if (pdata->paused) + frame_step = 0; pthread_mutex_unlock(&pdata->pause_mutex); - if (!pdata->args.nosound) - sync_streams(pdata, &frame_step, &delay); + if (frame_step) { + if (!pdata->args.nosound) + sync_streams(pdata, &frame_step, &delay); + + pthread_mutex_lock(&pdata->time_mutex); + pdata->time_frameno += frame_step; + pthread_mutex_unlock(&pdata->time_mutex); + } - pthread_mutex_lock(&pdata->time_mutex); - pdata->time_frameno += frame_step; - pthread_mutex_unlock(&pdata->time_mutex); pthread_cond_signal(&pdata->time_cond); nanosleep(&delay, NULL); |