summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-25 11:24:37 +0100
committerwm4 <wm4@nowhere>2013-12-25 11:32:29 +0100
commitf7516094500c543349fde0498c41bfcc72f21d2c (patch)
tree4dc354a22652547a8573bd45218fd43ec387e8d1
parent3720b3f17d4951ab839418b5cbfd1a85eb74adba (diff)
downloadmpv-f7516094500c543349fde0498c41bfcc72f21d2c.tar.bz2
mpv-f7516094500c543349fde0498c41bfcc72f21d2c.tar.xz
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.
-rw-r--r--options/options.c1
-rw-r--r--player/loadfile.c24
2 files changed, 22 insertions, 3 deletions
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);