From a609877f00889a5cb5fe3e4e2877eec49cc90ab0 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 2 Jul 2015 14:38:03 +0200 Subject: player: simplify reload logic Instead of only reloading the demuxer, reopen the stream as well. --- player/loadfile.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'player/loadfile.c') diff --git a/player/loadfile.c b/player/loadfile.c index f4ba0d4282..3b972f5ffc 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -1069,6 +1069,8 @@ static void play_current_file(struct MPContext *mpctx) MP_INFO(mpctx, "Playing: %s\n", mpctx->filename); +reopen_file: + assert(mpctx->stream == NULL); assert(mpctx->demuxer == NULL); assert(mpctx->d_audio == NULL); @@ -1105,8 +1107,6 @@ static void play_current_file(struct MPContext *mpctx) stream_set_capture_file(mpctx->stream, opts->stream_capture); -goto_reopen_demuxer: ; - mp_nav_reset(mpctx); open_demux_reentrant(mpctx); @@ -1242,16 +1242,6 @@ goto_reopen_demuxer: ; terminate_playback: - if (mpctx->stop_play == PT_RELOAD_DEMUXER) { - mpctx->stop_play = KEEP_PLAYING; - mpctx->playback_initialized = false; - uninit_audio_chain(mpctx); - uninit_video_chain(mpctx); - uninit_sub_all(mpctx); - uninit_demuxer(mpctx); - goto goto_reopen_demuxer; - } - process_unload_hooks(mpctx); mp_nav_destroy(mpctx); @@ -1279,13 +1269,18 @@ terminate_playback: if (!opts->gapless_audio && !mpctx->encode_lavc_ctx) uninit_audio_out(mpctx); + mpctx->playback_initialized = false; + + if (mpctx->stop_play == PT_RELOAD_FILE) { + mpctx->stop_play = KEEP_PLAYING; + goto reopen_file; + } + m_config_restore_backups(mpctx->mconfig); talloc_free(mpctx->filtered_tags); mpctx->filtered_tags = NULL; - mpctx->playback_initialized = false; - mp_notify(mpctx, MPV_EVENT_TRACKS_CHANGED, NULL); bool nothing_played = !mpctx->shown_aframes && !mpctx->shown_vframes && -- cgit v1.2.3