From c265f13978fbd68f295d99b2fe4720fe4866d64c Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Wed, 11 Nov 2020 23:44:15 -0800 Subject: timer: remove unnecessary timer thread This removes the timer thread entirely in favor of a coordinated delay loop directly within rmdGetFrame. When there's an audio stream to synchronize with, avd is maintained by the pcm buffer updates, and the fps-derived frametimes synchronize with the audio that way. When there's no audio stream (--no-sound), avd is now maintained synthetically via clock_gettime(CLOCK_MONOTONIC) coordinating with the clock instead. There's been some reworking of frame sampling/reusing and cloning logic, which may need some refinement. But for now the tests seem to show promise. The old timer approach just increased the non-determinism by adding more scheduler latency and influence unnecessarily. --- src/rmd_threads.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'src/rmd_threads.c') diff --git a/src/rmd_threads.c b/src/rmd_threads.c index 40fe94a..8514649 100644 --- a/src/rmd_threads.c +++ b/src/rmd_threads.c @@ -36,7 +36,6 @@ #include "rmd_get_frame.h" #include "rmd_jack.h" #include "rmd_register_callbacks.h" -#include "rmd_timer.h" #include "rmd_types.h" #include @@ -55,8 +54,7 @@ void rmdThreads(ProgData *pdata) sound_capture_t, sound_encode_t, sound_cache_t, - flush_to_ogg_t, - timer_t; + flush_to_ogg_t; if (pdata->args.delay > 0) { fprintf(stderr, "Will sleep for %d seconds now.\n", pdata->args.delay); @@ -106,11 +104,6 @@ void rmdThreads(ProgData *pdata) (void *)pdata); rmdRegisterCallbacks(pdata); - pdata->timer_alive = 1; - pthread_create( &timer_t, - NULL, - (void *)rmdTimer, - (void *)pdata); fprintf(stderr,"Capturing!\n"); #ifdef HAVE_LIBJACK @@ -165,10 +158,6 @@ void rmdThreads(ProgData *pdata) fprintf(stderr,".."); fprintf(stderr,"."); - - //Now that we are done with recording we cancel the timer - pdata->timer_alive = 0; - pthread_join(timer_t,NULL); } void rmdThreadsSetName(const char *name) -- cgit v1.2.1