diff --git a/options/options.c b/options/options.c index 5693a34cd0..7f98149369 100644 --- a/options/options.c +++ b/options/options.c @@ -709,6 +709,7 @@ const struct MPOpts mp_default_opts = { .audio_id = -1, .video_id = -1, .sub_id = -1, + .sub2_id = -2, .audio_display = 1, .sub_visibility = 1, .sub_pos = 100, diff --git a/player/loadfile.c b/player/loadfile.c index 99b669f109..251112975f 100644 --- a/player/loadfile.c +++ b/player/loadfile.c @@ -607,6 +607,12 @@ void mp_switch_track_n(struct MPContext *mpctx, int order, enum stream_type type if (track == current) return; + if (track && track->selected) { + // Track has been selected in a different order parameter. + MP_ERR(mpctx, "Track %d is already selected.\n", track->user_tid); + return; + } + if (order == 0) { if (type == STREAM_VIDEO) { int uninit = INITIALIZED_VCODEC; @@ -1193,9 +1199,21 @@ goto_reopen_demuxer: ; mpctx->current_track[0][STREAM_SUB] = select_track(mpctx, STREAM_SUB, mpctx->opts->sub_id, mpctx->opts->sub_lang); - for (int t = 0; t < mpctx->num_tracks; t++) { - struct track *track = mpctx->tracks[t]; - track->selected = track == mpctx->current_track[0][track->type]; + mpctx->current_track[1][STREAM_SUB] = + select_track(mpctx, STREAM_SUB, mpctx->opts->sub2_id, NULL); + for (int t = 0; t < STREAM_TYPE_COUNT; t++) { + for (int i = 0; i < NUM_PTRACKS; i++) { + struct track *track = mpctx->current_track[i][t]; + if (track) { + if (track->selected) { + MP_ERR(mpctx, "Track %d can't be selected twice.\n", + track->user_tid); + mpctx->current_track[i][t] = NULL; + } else { + track->selected = true; + } + } + } } reselect_demux_streams(mpctx);