summaryrefslogtreecommitdiffstats
path: root/core/mplayer.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-04-20 23:48:26 +0200
committerwm4 <wm4@nowhere>2013-04-20 23:48:26 +0200
commitc768a00dfe669b9406f9baba9c027cb1c9a19d6c (patch)
tree770b75c9066c5aaa8cc84a44db94dfe0a0d01f60 /core/mplayer.c
parent963c9aa3d5dc9514f6b4bdb9cc952454f2d83c3b (diff)
downloadmpv-c768a00dfe669b9406f9baba9c027cb1c9a19d6c.tar.bz2
mpv-c768a00dfe669b9406f9baba9c027cb1c9a19d6c.tar.xz
mplayer: prefer -sub/-subfile subs over auto-loaded subs
Before this commit, it was more or less random which subtitle was preferred if there was both an auto-loaded external subtitle, and a subtitle loaded via -sub or -subfile. -sub subtitles happened to be preferred over auto-loaded subs, while -subfile didn't. Fix the -subfile case, and make the behavior consistent by making the selection behavior explicit.
Diffstat (limited to 'core/mplayer.c')
-rw-r--r--core/mplayer.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/core/mplayer.c b/core/mplayer.c
index 3b6dd3984f..8bbae751a6 100644
--- a/core/mplayer.c
+++ b/core/mplayer.c
@@ -3593,6 +3593,7 @@ static int match_lang(char **langs, char *lang)
* Sort tracks based on the following criteria, and pick the first:
* 0) track matches tid (always wins)
* 1) track is external
+ * 1b) track was passed explicitly (is not an auto-loaded subtitle)
* 2) earlier match in lang list
* 3) track is marked default
* 4) lower track number
@@ -3605,6 +3606,8 @@ static bool compare_track(struct track *t1, struct track *t2, char **langs)
{
if (t1->is_external != t2->is_external)
return t1->is_external;
+ if (t1->auto_loaded != t2->auto_loaded)
+ return !t1->auto_loaded;
int l1 = match_lang(langs, t1->lang), l2 = match_lang(langs, t2->lang);
if (l1 != l2)
return l1 > l2;
@@ -3687,8 +3690,11 @@ static void open_subtitles_from_options(struct MPContext *mpctx)
if (mpctx->opts.sub_auto) { // auto load sub file ...
char **tmp = find_text_subtitles(&mpctx->opts, mpctx->filename);
int nsub = MP_TALLOC_ELEMS(tmp);
- for (int i = 0; i < nsub; i++)
- mp_add_subtitles(mpctx, tmp[i], sub_fps, 1);
+ for (int i = 0; i < nsub; i++) {
+ struct track *track = mp_add_subtitles(mpctx, tmp[i], sub_fps, 1);
+ if (track)
+ track->auto_loaded = true;
+ }
talloc_free(tmp);
}
}