mirror of
https://github.com/mpv-player/mpv
synced 2025-01-13 10:26:09 +00:00
player: fix initial selection with --secondary-sid
Also, make sure that a track can't be selected twice. While this might work in some situations, it certainly won't work with subtitles demuxed from a stream. Fixes #425.
This commit is contained in:
parent
3720b3f17d
commit
f751609450
@ -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,
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user