diff options
Diffstat (limited to 'video/out/vo.c')
-rw-r--r-- | video/out/vo.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/video/out/vo.c b/video/out/vo.c index a33d9fd15f..466759f595 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -141,6 +141,7 @@ struct vo_internal { double estimated_vsync_jitter; bool expecting_vsync; int64_t num_successive_vsyncs; + double last_vo_latency; int64_t flip_queue_offset; // queue flip events at most this much in advance int64_t timing_offset; // same (but from options; not VO configured) @@ -481,6 +482,10 @@ static void update_vsync_timing_after_swap(struct vo *vo) int64_t now = mp_time_us(); int64_t prev_vsync = in->prev_vsync; + // If we can, use a "made up" expected display time. + if (in->last_vo_latency >= 0) + now += in->last_vo_latency * (1000.0 * 1000.0); + in->prev_vsync = now; if (!in->expecting_vsync) { @@ -910,11 +915,15 @@ bool vo_render_frame_external(struct vo *vo) vo->driver->flip_page(vo); + double latency = + vo->driver->get_latency ? vo->driver->get_latency(vo) : -1; + MP_STATS(vo, "end video-flip"); pthread_mutex_lock(&in->lock); in->dropped_frame = prev_drop_count < vo->in->drop_count; in->rendering = false; + in->last_vo_latency = latency; update_vsync_timing_after_swap(vo); } |