1
0
mirror of https://github.com/mpv-player/mpv synced 2025-01-30 03:32:50 +00:00

player: reset playback-related fields right on start

This commit is contained in:
wm4 2014-09-01 21:02:43 +02:00
parent 27a065182c
commit e87617593f

View File

@ -1019,6 +1019,20 @@ static void play_current_file(struct MPContext *mpctx)
mpctx->filename = NULL;
mpctx->shown_aframes = 0;
mpctx->shown_vframes = 0;
mpctx->last_vo_pts = MP_NOPTS_VALUE;
mpctx->last_chapter_seek = -2;
mpctx->last_chapter_pts = MP_NOPTS_VALUE;
mpctx->last_chapter = -2;
mpctx->paused = false;
mpctx->paused_for_cache = false;
mpctx->playing_msg_shown = false;
mpctx->step_frames = 0;
mpctx->backstep_active = false;
mpctx->audio_delay = 0;
mpctx->max_frames = -1;
mpctx->seek = (struct seek_params){ 0 };
reset_playback_state(mpctx);
if (mpctx->playlist->current)
mpctx->filename = mpctx->playlist->current->filename;
@ -1030,10 +1044,6 @@ static void play_current_file(struct MPContext *mpctx)
if (local_filename)
mpctx->filename = local_filename;
#if HAVE_ENCODING
encode_lavc_discontinuity(mpctx->encode_lavc_ctx);
#endif
mpctx->add_osd_seek_info &= OSD_SEEK_INFO_EDITION;
if (opts->reset_options) {
@ -1062,9 +1072,10 @@ static void play_current_file(struct MPContext *mpctx)
ass_set_style_overrides(mpctx->ass_library, opts->ass_force_style_list);
#endif
MP_INFO(mpctx, "Playing: %s\n", mpctx->filename);
mpctx->audio_delay = opts->audio_delay;
mpctx->max_frames = opts->play_frames;
//============ Open & Sync STREAM --- fork cache2 ====================
MP_INFO(mpctx, "Playing: %s\n", mpctx->filename);
assert(mpctx->stream == NULL);
assert(mpctx->demuxer == NULL);
@ -1115,8 +1126,6 @@ goto_reopen_demuxer: ;
//============ Open DEMUXERS --- DETECT file type =======================
mpctx->audio_delay = opts->audio_delay;
mpctx->demuxer = demux_open(mpctx->stream, opts->demuxer_name, NULL,
mpctx->global);
mpctx->master_demuxer = mpctx->demuxer;
@ -1250,26 +1259,11 @@ goto_reopen_demuxer: ;
MP_VERBOSE(mpctx, "Starting playback...\n");
mpctx->max_frames = opts->play_frames;
if (mpctx->max_frames == 0) {
mpctx->stop_play = PT_NEXT_ENTRY;
goto terminate_playback;
}
reset_playback_state(mpctx);
mpctx->last_vo_pts = MP_NOPTS_VALUE;
mpctx->last_chapter_seek = -2;
mpctx->last_chapter_pts = MP_NOPTS_VALUE;
mpctx->last_chapter = -2;
mpctx->paused = false;
mpctx->paused_for_cache = false;
mpctx->playing_msg_shown = false;
mpctx->step_frames = 0;
mpctx->backstep_active = false;
mpctx->seek = (struct seek_params){ 0 };
// If there's a timeline force an absolute seek to initialize state
double startpos = rel_time_to_abs(mpctx, opts->play_start);
if (startpos == MP_NOPTS_VALUE && mpctx->resolve_result &&