summaryrefslogtreecommitdiff
path: root/src/rmd_timer.c
AgeCommit message (Collapse)Author
2020-11-12timer: remove unnecessary timer threadVito Caputo
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.
2020-11-11*: add _us suffixes to {frame,period}time namesVito Caputo
Make the names reflect their units of microseconds
2020-10-30*: more minor cleanupsVito Caputo
No need for fflush(stderr) when it's already unbuffered by default. According to setvbuf(3): Normally all files are block buffered. If a stream refers to a terminal (as stdout normally does), it is line buffered. The standard error stream stderr is always unbuffered by default.
2020-10-08*: more cosmetic formatting cleanupsVito Caputo
Making things a bit more consistent
2020-07-15timer: maintain video side of avd in frame timerVito Caputo
Since the frame timer implements a frame counter, and that frame count is propagated through the get->encode pipeline for samples that get through, any missed frames are noticed and dealt with making it not lossy from the point of the timer down to the encoded stream in terms of number of frames. It's certainly lossy in terms of the contents of those frames, but synchronization is all about the temporal domain and as long as the frame counts all make it into the stream as frames, we can account for them at the timer in terms of avd. This in combination with the other commit moving the audio side of avd maintenance immediately upon capture into the raw buffer, shrinks the variable capacitance separating the audio timer and the frame timer to virtually nil. As a consequence, the frame timer can now be much more accurate in terms of how much longer/less to sleep or if a frame should be dropped to get the timer caught up. When avd was being maintained at points far removed from the actual things they represented there was too much elastic capacitance in there for sync_streams() to inform its adjustment accurately.
2020-07-14timer: don't advance time_frameno when pausedVito Caputo
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.
2020-07-14*: get rid of unused frames_{total,lost}Vito Caputo
these concepts may return but not in this form
2020-07-14timer: implement AV-syncVito Caputo
This is focused on keeping --on-the-fly-encoding in sync even over long videos. The existing code inevitably would fall into a permanently negative pdata->avd value letting things get increasingly out of sync and never correcting. Before removing the vestigial negative avd "don't wait" logic from get_frame when this permanently negative avd state was entered, get_frame would just start sampling at an unregulated fps. The timer thread which drives get_frame now consults avd on every tick, Depending on which which half is ahead, the timer will either cause get_frame to drop frames by advancing the frameno by more than one, or it will adjust its sleep delay in proportion to the delta. See comments in rmd_timer.c for more details. Note that in testing especially with a loaded system I observed some surprisingly large deltas where multi-second sleeps occurred to let the sound catch back up. I expect to revisit this issue more in the future, but would just like to get things more correct for now.
2020-07-13*: more rmdThreadsSetName() callersVito Caputo
Name the timer and sound capture threads as well, and fixup the rmd{Encode,Cache}Sounds names -> rmd{Encode,Cache}Sound
2020-07-12*: standardize sleeps on nanosleep()Vito Caputo
usleep() is deprecated by posix in favor of nanosleep(), nanosleep doesn't dick with signals so it's generally better anyways.
2020-07-11*: drop {gtk,qt}-recordmydesktop subdirsVito Caputo
This restores the recordmydesktop/ subdir as root from the mirror I cloned by fork from. I have no particular interest in the gtk/qt frontends and it doesn't appear they were part of a single tree in the past. But I will probably preserve backwards compatibility of the cli so they can continue to work with this fork installed.
© All Rights Reserved