From 8f2e9f1d613f686a834446c73465f0ca41156db3 Mon Sep 17 00:00:00 2001 From: wm4 Date: Wed, 30 Jul 2014 23:01:55 +0200 Subject: player: split seek_reset() This also reduces some code duplication with other parts of the code. The changfe is mostly cosmetic, although there are also some subtle changes in behavior. At least one change is that the big desync message is now printed after every seek. --- player/video.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'player/video.c') diff --git a/player/video.c b/player/video.c index dacf1200c5..713849798b 100644 --- a/player/video.c +++ b/player/video.c @@ -168,6 +168,26 @@ int reinit_video_filters(struct MPContext *mpctx) return d_video->vfilter->initialized; } +void reset_video_state(struct MPContext *mpctx) +{ + if (mpctx->d_video) + video_reset_decoding(mpctx->d_video); + if (mpctx->video_out) + vo_seek_reset(mpctx->video_out); + + mpctx->delay = 0; + mpctx->time_frame = 0; + mpctx->video_next_pts = MP_NOPTS_VALUE; + mpctx->playing_last_frame = false; + mpctx->last_frame_duration = 0; + mpctx->total_avsync_change = 0; + mpctx->drop_frame_cnt = 0; + mpctx->dropped_frames = 0; + mpctx->drop_message_shown = 0; + + mpctx->video_status = mpctx->d_video ? STATUS_SYNCING : STATUS_EOF; +} + int reinit_video_chain(struct MPContext *mpctx) { struct MPOpts *opts = mpctx->opts; @@ -223,21 +243,15 @@ int reinit_video_chain(struct MPContext *mpctx) vo_control(mpctx->video_out, mpctx->paused ? VOCTRL_PAUSE : VOCTRL_RESUME, NULL); - mpctx->video_status = STATUS_SYNCING; mpctx->sync_audio_to_video = !sh->attached_picture; - mpctx->delay = 0; - mpctx->video_next_pts = MP_NOPTS_VALUE; - mpctx->playing_last_frame = false; - mpctx->last_frame_duration = 0; mpctx->vo_pts_history_seek_ts++; // If we switch on video again, ensure audio position matches up. if (mpctx->d_audio) mpctx->audio_status = STATUS_SYNCING; - vo_seek_reset(mpctx->video_out); - reset_subtitles(mpctx, 0); - reset_subtitles(mpctx, 1); + reset_video_state(mpctx); + reset_subtitle_state(mpctx); if (opts->force_fps) { d_video->fps = opts->force_fps; -- cgit v1.2.3