From 7dff6a28429b38cd9286a6b7b91fbe6eab72a114 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 25 Dec 2015 13:40:06 +0100 Subject: player: fix previous commit OK, this made the --sub-paths and --audio-file-paths synonyms, which is not what we wanted. Actually restrict the type of file loaded as well. Really fixes #2632. --- player/external_files.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'player/external_files.c') diff --git a/player/external_files.c b/player/external_files.c index 5dedfc920f..c1b7d53c3c 100644 --- a/player/external_files.c +++ b/player/external_files.c @@ -87,7 +87,7 @@ static struct bstr guess_lang_from_filename(struct bstr name) static void append_dir_subtitles(struct mpv_global *global, struct subfn **slist, int *nsub, struct bstr path, const char *fname, - int limit_fuzziness) + int limit_fuzziness, int limit_type) { void *tmpmem = talloc_new(NULL); struct MPOpts *opts = global->opts; @@ -136,7 +136,7 @@ static void append_dir_subtitles(struct mpv_global *global, break; } - if (fuzz < 0) + if (fuzz < 0 || (limit_type >= 0 && limit_type != type)) goto next_sub; // we have a (likely) subtitle file @@ -228,18 +228,20 @@ static void filter_subidx(struct subfn **slist, int *nsub) static void load_paths(struct mpv_global *global, struct subfn **slist, int *nsubs, const char *fname, char **paths, - char *cfg_path) + char *cfg_path, int type) { for (int i = 0; paths && paths[i]; i++) { char *path = mp_path_join_bstr(*slist, mp_dirname(fname), bstr0(paths[i])); - append_dir_subtitles(global, slist, nsubs, bstr0(path), fname, 0); + append_dir_subtitles(global, slist, nsubs, bstr0(path), fname, 0, type); } // Load subtitles in ~/.mpv/sub (or similar) limiting sub fuzziness char *mp_subdir = mp_find_config_file(NULL, global, cfg_path); - if (mp_subdir) - append_dir_subtitles(global, slist, nsubs, bstr0(mp_subdir), fname, 1); + if (mp_subdir) { + append_dir_subtitles(global, slist, nsubs, bstr0(mp_subdir), fname, 1, + type); + } talloc_free(mp_subdir); } @@ -252,14 +254,18 @@ struct subfn *find_external_files(struct mpv_global *global, const char *fname) int n = 0; // Load subtitles from current media directory - append_dir_subtitles(global, &slist, &n, mp_dirname(fname), fname, 0); + append_dir_subtitles(global, &slist, &n, mp_dirname(fname), fname, 0, -1); // Load subtitles in dirs specified by sub-paths option - if (opts->sub_auto >= 0) - load_paths(global, &slist, &n, fname, opts->sub_paths, "sub/"); + if (opts->sub_auto >= 0) { + load_paths(global, &slist, &n, fname, opts->sub_paths, "sub/", + STREAM_SUB); + } - if (opts->audiofile_auto >= 0) - load_paths(global, &slist, &n, fname, opts->audiofile_paths, "audio/"); + if (opts->audiofile_auto >= 0) { + load_paths(global, &slist, &n, fname, opts->audiofile_paths, "audio/", + STREAM_AUDIO); + } // Sort by name for filter_subidx() qsort(slist, n, sizeof(*slist), compare_sub_filename); -- cgit v1.2.3