diff options
author | wm4 <wm4@nowhere> | 2013-11-25 23:38:51 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-11-25 23:41:02 +0100 |
commit | ce4d1f461a31da6adae370087f0516312c9410e4 (patch) | |
tree | 76d2293035ebab00eba9b04bc541896dfbb9474b /mpvcore/player | |
parent | 78fa766fcc61e7402ec3b2d0de842ebeb84b5639 (diff) | |
download | mpv-ce4d1f461a31da6adae370087f0516312c9410e4.tar.bz2 mpv-ce4d1f461a31da6adae370087f0516312c9410e4.tar.xz |
sub: respect detected language for fuzzy-matched external subtitles
Solve this by passing through the language to the player, which then
uses the generic subtitle selection code to make a choice.
Fixes #367.
Diffstat (limited to 'mpvcore/player')
-rw-r--r-- | mpvcore/player/loadfile.c | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/mpvcore/player/loadfile.c b/mpvcore/player/loadfile.c index a913c25519..46574898e5 100644 --- a/mpvcore/player/loadfile.c +++ b/mpvcore/player/loadfile.c @@ -697,20 +697,23 @@ static void open_subtitles_from_options(struct MPContext *mpctx) mp_add_subtitles(mpctx, mpctx->opts->sub_name[i]); } 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++) { - char *filename = tmp[i]; + struct subfn *list = find_text_subtitles(mpctx->opts, mpctx->filename); + for (int i = 0; list[i].fname; i++) { + char *filename = list[i].fname; + char *lang = list[i].lang; for (int n = 0; n < mpctx->num_sources; n++) { if (strcmp(mpctx->sources[n]->stream->url, filename) == 0) goto skip; } struct track *track = mp_add_subtitles(mpctx, filename); - if (track) + if (track) { track->auto_loaded = true; + if (!track->lang) + track->lang = talloc_strdup(track, lang); + } skip:; } - talloc_free(tmp); + talloc_free(list); } } |