From 77b06fa017c70491c9b3820fdf14aeeb27b6088c Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 28 Oct 2014 15:30:27 +0100 Subject: player: handle edition reloading slightly differently Use the codepath that is normally used for DVD/BD title switching and DVB channel switching. Removes some extra artifacts from the client API: now MPV_EVENT_END_FILE will never be called on reloads (and neither is MPV_EVENT_START_FILE). --- player/command.c | 2 +- player/core.h | 3 +-- player/loadfile.c | 17 +++++++++-------- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'player') diff --git a/player/command.c b/player/command.c index 0806cd093c..752a62de8f 100644 --- a/player/command.c +++ b/player/command.c @@ -809,7 +809,7 @@ static int mp_property_edition(void *ctx, struct m_property *prop, edition = *(int *)arg; if (edition != demuxer->edition) { opts->edition_id = edition; - mpctx->stop_play = PT_RESTART; + mpctx->stop_play = PT_RELOAD_DEMUXER; } return M_PROPERTY_OK; } diff --git a/player/core.h b/player/core.h index c0a00e454b..9b9873e610 100644 --- a/player/core.h +++ b/player/core.h @@ -36,7 +36,6 @@ enum stop_play_reason { PT_NEXT_ENTRY, // prepare to play next entry in playlist PT_CURRENT_ENTRY, // prepare to play mpctx->playlist->current PT_STOP, // stop playback, clear playlist - PT_RESTART, // restart previous file PT_RELOAD_DEMUXER, // restart playback, but keep stream open PT_QUIT, // stop playback, quit player }; @@ -192,6 +191,7 @@ typedef struct MPContext { int64_t shown_vframes, shown_aframes; + struct stream *stream; // stream that was initially opened struct demuxer **sources; int num_sources; @@ -202,7 +202,6 @@ typedef struct MPContext { int num_chapters; double video_offset; - struct stream *stream; struct demuxer *demuxer; struct track **tracks; diff --git a/player/loadfile.c b/player/loadfile.c index cea0624b15..68d8f78da1 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -270,7 +270,6 @@ bool timeline_set_part(struct MPContext *mpctx, int i, bool force) } mpctx->demuxer = n->source; - mpctx->stream = mpctx->demuxer->stream; // While another timeline was active, the selection of active tracks might // have been changed - possibly we need to update this source. @@ -841,6 +840,7 @@ static struct stream *open_stream_async(struct MPContext *mpctx, struct demux_open_args { struct stream *stream; + struct mpv_global *global; struct demuxer *demux; // result }; @@ -848,15 +848,20 @@ static void open_demux_thread(void *pctx) { struct demux_open_args *args = pctx; struct stream *s = args->stream; - struct mpv_global *global = s->global; // they run in the same thread anyway + struct mpv_global *global = args->global; args->demux = demux_open(s, global->opts->demuxer_name, NULL, global); } static struct demuxer *open_demux_async(struct MPContext *mpctx, struct stream *stream) { - struct demux_open_args args = {stream}; + struct demux_open_args args = {stream, create_sub_global(mpctx)}; mpctx_run_non_blocking(mpctx, open_demux_thread, &args); + if (args.demux) { + talloc_steal(args.demux, args.global); + } else { + talloc_free(args.global); + } return args.demux; } @@ -1016,7 +1021,6 @@ goto_reopen_demuxer: ; if (mpctx->timeline) timeline_set_part(mpctx, mpctx->timeline_part, true); - open_subtitles_from_options(mpctx); open_audiofiles_from_options(mpctx); @@ -1165,8 +1169,7 @@ terminate_playback: if (!opts->gapless_audio && !mpctx->encode_lavc_ctx) uninit_audio_out(mpctx); - if (mpctx->stop_play != PT_RESTART) - m_config_restore_backups(mpctx->mconfig); + m_config_restore_backups(mpctx->mconfig); mpctx->playback_initialized = false; @@ -1182,8 +1185,6 @@ terminate_playback: struct mpv_event_end_file end_event = {0}; switch (mpctx->stop_play) { case AT_END_OF_FILE: end_event.reason = 0; break; - case PT_RESTART: - case PT_RELOAD_DEMUXER: end_event.reason = 1; break; case PT_NEXT_ENTRY: case PT_CURRENT_ENTRY: case PT_STOP: end_event.reason = 2; break; -- cgit v1.2.3