diff options
author | wm4 <wm4@nowhere> | 2018-08-31 20:08:08 +0200 |
---|---|---|
committer | Anton Kindestam <antonki@kth.se> | 2018-12-06 10:30:25 +0100 |
commit | b1ba7de34dd5685a082454817f23509d1c28e4aa (patch) | |
tree | dc7c077d64742cb728c88fc582f952718a61155d /video/out/vo.c | |
parent | 83884fdf03fc991679bea53d3d5bddf97ed16a9b (diff) | |
download | mpv-b1ba7de34dd5685a082454817f23509d1c28e4aa.tar.bz2 mpv-b1ba7de34dd5685a082454817f23509d1c28e4aa.tar.xz |
vo: use a struct for vsync feedback stuff
So new useless stuff can be easily added.
Diffstat (limited to 'video/out/vo.c')
-rw-r--r-- | video/out/vo.c | 32 |
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) { |