summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--player/command.c6
-rw-r--r--player/core.h2
-rw-r--r--player/loadfile.c29
3 files changed, 29 insertions, 8 deletions
diff --git a/player/command.c b/player/command.c
index 69bfba0975..0b135d187f 100644
--- a/player/command.c
+++ b/player/command.c
@@ -1178,11 +1178,13 @@ static int property_switch_track(m_option_t *prop, int action, void *arg,
struct m_property_switch_arg *sarg = arg;
mp_switch_track_n(mpctx, order, type,
track_next(mpctx, order, type, sarg->inc >= 0 ? +1 : -1, track));
+ mp_mark_user_track_selection(mpctx, order, type);
return M_PROPERTY_OK;
}
case M_PROPERTY_SET:
track = mp_track_by_tid(mpctx, type, *(int *)arg);
mp_switch_track_n(mpctx, order, type, track);
+ mp_mark_user_track_selection(mpctx, order, type);
return M_PROPERTY_OK;
}
return mp_property_generic_option(prop, action, arg, mpctx);
@@ -3240,8 +3242,10 @@ void run_command(MPContext *mpctx, mp_cmd_t *cmd)
case MP_CMD_SUB_ADD: {
struct track *sub = mp_add_subtitles(mpctx, cmd->args[0].v.s);
- if (sub)
+ if (sub) {
mp_switch_track(mpctx, sub->type, sub);
+ mp_mark_user_track_selection(mpctx, 0, sub->type);
+ }
break;
}
diff --git a/player/core.h b/player/core.h
index 9ece9ebb4d..fd9be5bcd4 100644
--- a/player/core.h
+++ b/player/core.h
@@ -385,6 +385,8 @@ void mp_switch_track(struct MPContext *mpctx, enum stream_type type,
void mp_switch_track_n(struct MPContext *mpctx, int order,
enum stream_type type, struct track *track);
void mp_deselect_track(struct MPContext *mpctx, struct track *track);
+void mp_mark_user_track_selection(struct MPContext *mpctx, int order,
+ enum stream_type type);
struct track *mp_track_by_tid(struct MPContext *mpctx, enum stream_type type,
int tid);
bool timeline_set_part(struct MPContext *mpctx, int i, bool force);
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)
{