From ce4d1f461a31da6adae370087f0516312c9410e4 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 25 Nov 2013 23:38:51 +0100 Subject: 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. --- mpvcore/player/loadfile.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'mpvcore') 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); } } -- cgit v1.2.3