0
0
mirror of https://github.com/mpv-player/mpv.git synced 2024-09-20 12:02:23 +02:00

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).
This commit is contained in:
wm4 2014-10-28 15:30:27 +01:00
parent 0da9ee79e7
commit 77b06fa017
3 changed files with 11 additions and 11 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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;