From 9afd62bfcd4ddf2a8339b3ac3c95d607be610ce4 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 27 Nov 2015 21:50:59 +0100 Subject: vo: fix audio-timing framedrop regressions Commit 12eb8b2d accidentally disabled framedropping in the audio timing case. It tried to replace the last_flip field with the prev_vsync one, which didn't work because prev_sync is reset to 0 if the timing code is used. Fix it by always setting it properly. This field must (or should) be reinitialized to something sensible when switching to display sync timing mode; since prev_vsync is not reset anymore, the check when to reinitialize this field has to be adjusted as well. It's a bit weird that update_vsync_timing_after_swap() now does some minor work for timing mode too, but I guess it's ok, if only to avoid additional fields and timer calls. --- video/out/vo.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'video') diff --git a/video/out/vo.c b/video/out/vo.c index 808f543f1f..c117e5fccf 100644 --- a/video/out/vo.c +++ b/video/out/vo.c @@ -325,7 +325,6 @@ static void reset_vsync_timings(struct vo *vo) struct vo_internal *in = vo->in; in->num_vsync_samples = 0; in->drop_point = 0; - in->prev_vsync = 0; in->estimated_vsync_interval = 0; in->estimated_vsync_jitter = -1; in->base_vsync = 0; @@ -348,12 +347,14 @@ static void update_vsync_timing_after_swap(struct vo *vo) { struct vo_internal *in = vo->in; - if (!in->expecting_vsync || !in->prev_vsync) { + int64_t now = mp_time_us(); + + if (!in->expecting_vsync) { + in->prev_vsync = now; // for normal system-time framedrop reset_vsync_timings(vo); return; } - int64_t now = mp_time_us(); int max_samples = 200; if (in->num_vsync_samples >= max_samples) in->num_vsync_samples -= 1; @@ -764,7 +765,7 @@ static bool render_frame(struct vo *vo) in->current_frame->num_vsyncs -= 1; in->expecting_vsync = in->current_frame->display_synced && !in->paused; - if (in->expecting_vsync && !in->prev_vsync) + if (in->expecting_vsync && !in->num_vsync_samples) // first DS frame in a row in->prev_vsync = mp_time_us(); if (in->dropped_frame) { -- cgit v1.2.3