0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-19 20:32:15 +02:00

libobs: Save clamped video time

The "clamped" video time is the system time per video frame that is
closest to the current system time, but always divisible by the frame
interval.  For example, if the last frame system timestamp was 1600 and
the new frame is 2500, but the frame interval is 800, then the
"clamped" video time is 2400.

This clamped value is useful to get the relative system time without any
jitter.
This commit is contained in:
jp9000 2015-06-04 16:48:56 -07:00
parent 7f7901b930
commit 51dd204c6f
2 changed files with 5 additions and 3 deletions

View File

@ -217,6 +217,7 @@ struct obs_core_video {
gs_stagesurf_t *mapped_surface;
int cur_texture;
uint64_t video_time;
video_t *video;
pthread_t video_thread;
bool thread_initialized;

View File

@ -562,17 +562,18 @@ static inline void output_frame(uint64_t *cur_time, uint64_t interval)
void *obs_video_thread(void *param)
{
uint64_t last_time = 0;
uint64_t cur_time = os_gettime_ns();
uint64_t interval = video_output_get_frame_time(obs->video.video);
obs->video.video_time = os_gettime_ns();
os_set_thread_name("libobs: graphics thread");
while (!video_output_stopped(obs->video.video)) {
last_time = tick_sources(cur_time, last_time);
last_time = tick_sources(obs->video.video_time, last_time);
render_displays();
output_frame(&cur_time, interval);
output_frame(&obs->video.video_time, interval);
}
UNUSED_PARAMETER(param);