summaryrefslogtreecommitdiffstats
path: root/video/out/vo.c
diff options
context:
space:
mode:
Diffstat (limited to 'video/out/vo.c')
-rw-r--r--video/out/vo.c32
1 files changed, 17 insertions, 15 deletions
diff --git a/video/out/vo.c b/video/out/vo.c
index 466759f595..4110e1f353 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -141,7 +141,6 @@ 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)
@@ -475,18 +474,14 @@ static void vsync_skip_detection(struct vo *vo)
}
// Always called locked.
-static void update_vsync_timing_after_swap(struct vo *vo)
+static void update_vsync_timing_after_swap(struct vo *vo,
+ struct vo_vsync_info *vsync)
{
struct vo_internal *in = vo->in;
- int64_t now = mp_time_us();
+ int64_t vsync_time = vsync->last_queue_time;
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;
+ in->prev_vsync = vsync_time;
if (!in->expecting_vsync) {
reset_vsync_timings(vo);
@@ -500,13 +495,13 @@ static void update_vsync_timing_after_swap(struct vo *vo)
if (in->num_vsync_samples >= MAX_VSYNC_SAMPLES)
in->num_vsync_samples -= 1;
MP_TARRAY_INSERT_AT(in, in->vsync_samples, in->num_vsync_samples, 0,
- now - prev_vsync);
+ vsync_time - prev_vsync);
in->drop_point = MPMIN(in->drop_point + 1, in->num_vsync_samples);
in->num_total_vsync_samples += 1;
if (in->base_vsync) {
in->base_vsync += in->vsync_interval;
} else {
- in->base_vsync = now;
+ in->base_vsync = vsync_time;
}
double avg = 0;
@@ -915,17 +910,24 @@ 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;
+ struct vo_vsync_info vsync = {
+ .last_queue_time = mp_time_us(),
+ .latency = -1,
+ };
+ if (vo->driver->get_vsync)
+ vo->driver->get_vsync(vo, &vsync);
+
+ // If we can, use a "made up" expected display time.
+ if (vsync.latency >= 0)
+ vsync.last_queue_time += vsync.latency * (1000.0 * 1000.0);
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);
+ update_vsync_timing_after_swap(vo, &vsync);
}
if (vo->driver->caps & VO_CAP_NORETAIN) {