summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-12-25 13:40:06 +0100
committerwm4 <wm4@nowhere>2015-12-25 13:40:06 +0100
commit7dff6a28429b38cd9286a6b7b91fbe6eab72a114 (patch)
tree4db44a82ef42b3e0a8cb5b6ead9ec28b82bb86aa
parent0710ced0792f3ec83c337d1b4f48ff13950f7f33 (diff)
downloadmpv-7dff6a28429b38cd9286a6b7b91fbe6eab72a114.tar.bz2
mpv-7dff6a28429b38cd9286a6b7b91fbe6eab72a114.tar.xz
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.
-rw-r--r--player/external_files.c28
1 files changed, 17 insertions, 11 deletions
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);