From 59d9007e15fe30fd0ed24580eb461ae02d497f40 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 3 Mar 2014 23:53:12 +0100 Subject: player: make separation between user/automatic track selection stronger For example, consider the case when audio initialization fails. Then the audio track is deselected. Before this commit, this would have been equivalent to the user disabling audio. This is bad when multiple files are played at once (the next file would have audio disabled, even if it works), or if playback resume is used (if e.g. audio output failed to initialize, then audio would be disabled when resuming, even if the system's audio driver was fixed). --- player/loadfile.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'player/loadfile.c') diff --git a/player/loadfile.c b/player/loadfile.c index 28c4c4f146..fbd9797490 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -662,23 +662,17 @@ void mp_switch_track_n(struct MPContext *mpctx, int order, enum stream_type type reselect_demux_streams(mpctx); - int user_tid = track ? track->user_tid : -2; if (order == 0) { if (type == STREAM_VIDEO) { - mpctx->opts->video_id = user_tid; reinit_video_chain(mpctx); } else if (type == STREAM_AUDIO) { - mpctx->opts->audio_id = user_tid; reinit_audio_chain(mpctx); } else if (type == STREAM_SUB) { - mpctx->opts->sub_id = user_tid; reinit_subs(mpctx, 0); } } else if (order == 1) { - if (type == STREAM_SUB) { - mpctx->opts->sub2_id = user_tid; + if (type == STREAM_SUB) reinit_subs(mpctx, 1); - } } mp_notify(mpctx, MPV_EVENT_TRACK_SWITCHED, NULL); @@ -702,6 +696,27 @@ void mp_deselect_track(struct MPContext *mpctx, struct track *track) } } +// Mark the current track selection as explicitly user-requested. (This is +// different from auto-selection or disabling a track due to errors.) +void mp_mark_user_track_selection(struct MPContext *mpctx, int order, + enum stream_type type) +{ + struct track *track = mpctx->current_track[order][type]; + int user_tid = track ? track->user_tid : -2; + if (order == 0) { + if (type == STREAM_VIDEO) { + mpctx->opts->video_id = user_tid; + } else if (type == STREAM_AUDIO) { + mpctx->opts->audio_id = user_tid; + } else if (type == STREAM_SUB) { + mpctx->opts->sub_id = user_tid; + } + } else if (order == 1) { + if (type == STREAM_SUB) + mpctx->opts->sub2_id = user_tid; + } +} + struct track *mp_track_by_tid(struct MPContext *mpctx, enum stream_type type, int tid) { -- cgit v1.2.3