diff options
author | wm4 <wm4@nowhere> | 2015-11-13 22:49:50 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2015-11-13 22:49:50 +0100 |
commit | 07b8abbd62c8d5b28f52a3e5e0192f16cad2405b (patch) | |
tree | 847f85ae32a841576c33258ec8c0154423950786 /player | |
parent | d5981924feb02384f9facbedc9fff2fb89ac8db3 (diff) |
player: remove display_sync_disable_counter
We can implement it differently and drop a tiny bit of state.
Diffstat (limited to 'player')
-rw-r--r-- | player/core.h | 1 | ||||
-rw-r--r-- | player/video.c | 18 |
2 files changed, 8 insertions, 11 deletions
diff --git a/player/core.h b/player/core.h index 7031efc107..ed433b098c 100644 --- a/player/core.h +++ b/player/core.h @@ -273,7 +273,6 @@ typedef struct MPContext { // Timing error (in seconds) due to rounding on vsync boundaries double display_sync_error; double audio_drop_throttle; - int display_sync_disable_counter; // Number of mistimed frames. int mistimed_frames_total; /* Set if audio should be timed to start with video frame after seeking, diff --git a/player/video.c b/player/video.c index 5ef327aa09..281789e2a4 100644 --- a/player/video.c +++ b/player/video.c @@ -209,7 +209,6 @@ void reset_video_state(struct MPContext *mpctx) mpctx->num_past_frames = 0; mpctx->total_avsync_change = 0; mpctx->last_av_difference = 0; - mpctx->display_sync_disable_counter = 0; mpctx->dropped_frames_total = 0; mpctx->dropped_frames = 0; mpctx->mistimed_frames_total = 0; @@ -901,7 +900,6 @@ static void handle_display_sync_frame(struct MPContext *mpctx, { struct MPOpts *opts = mpctx->opts; struct vo *vo = mpctx->video_out; - bool old_display_sync = mpctx->display_sync_active; int mode = opts->video_sync; if (!mpctx->display_sync_active) { @@ -946,10 +944,11 @@ static void handle_display_sync_frame(struct MPContext *mpctx, // But if we switch too often between these modes, keep it disabled. In // fact, we disable it if it just wants to switch between enable/disable // more than once in the last N frames. - if (!old_display_sync) { - if (mpctx->display_sync_disable_counter > 0) - goto done; // keep disabled - mpctx->display_sync_disable_counter = 50; + if (mpctx->num_past_frames > 1 && mpctx->past_frames[1].num_vsyncs < 0) { + for (int n = 1; n < mpctx->num_past_frames; n++) { + if (mpctx->past_frames[n].num_vsyncs >= 0) + goto done; + } } // Determine for how many vsyncs a frame should be displayed. This can be @@ -1018,13 +1017,12 @@ done: update_playback_speed(mpctx); - if (old_display_sync != mpctx->display_sync_active) { + if (mpctx->num_past_frames > 1 && + ((mpctx->past_frames[1].num_vsyncs >= 0) != mpctx->display_sync_active)) + { MP_VERBOSE(mpctx, "Video sync mode %s.\n", mpctx->display_sync_active ? "enabled" : "disabled"); } - - mpctx->display_sync_disable_counter = - MPMAX(0, mpctx->display_sync_disable_counter - 1); } static void schedule_frame(struct MPContext *mpctx, struct vo_frame *frame) |