summaryrefslogtreecommitdiffstats
path: root/player
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-12-25 13:17:11 +0100
committerwm4 <wm4@nowhere>2015-12-25 13:17:11 +0100
commit0710ced0792f3ec83c337d1b4f48ff13950f7f33 (patch)
treed370c75f08f11d4aa661aaae55e56f353a3bfe93 /player
parent6d9cb89333782c1c7043f58cc4b0c713c2e871d6 (diff)
downloadmpv-0710ced0792f3ec83c337d1b4f48ff13950f7f33.tar.bz2
mpv-0710ced0792f3ec83c337d1b4f48ff13950f7f33.tar.xz
options: add --audio-file-paths
Requested. It works like --sub-paths. This will also load audio files from a "audio" sub directory in the config file (because the same code as for subtitles is used, and it also had such a feature). Fixes #2632.
Diffstat (limited to 'player')
-rw-r--r--player/external_files.c37
1 files changed, 22 insertions, 15 deletions
diff --git a/player/external_files.c b/player/external_files.c
index 486b492dd2..5dedfc920f 100644
--- a/player/external_files.c
+++ b/player/external_files.c
@@ -226,6 +226,23 @@ 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)
+{
+ 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);
+ }
+
+ // 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);
+ talloc_free(mp_subdir);
+}
+
// Return a list of subtitles and audio files found, sorted by priority.
// Last element is terminated with a fname==NULL entry.
struct subfn *find_external_files(struct mpv_global *global, const char *fname)
@@ -237,22 +254,12 @@ struct subfn *find_external_files(struct mpv_global *global, const char *fname)
// Load subtitles from current media directory
append_dir_subtitles(global, &slist, &n, mp_dirname(fname), fname, 0);
- if (opts->sub_auto >= 0) {
- // Load subtitles in dirs specified by sub-paths option
- if (opts->sub_paths) {
- for (int i = 0; opts->sub_paths[i]; i++) {
- char *path = mp_path_join_bstr(slist, mp_dirname(fname),
- bstr0(opts->sub_paths[i]));
- append_dir_subtitles(global, &slist, &n, bstr0(path), fname, 0);
- }
- }
+ // Load subtitles in dirs specified by sub-paths option
+ if (opts->sub_auto >= 0)
+ load_paths(global, &slist, &n, fname, opts->sub_paths, "sub/");
- // Load subtitles in ~/.mpv/sub limiting sub fuzziness
- char *mp_subdir = mp_find_config_file(NULL, global, "sub/");
- if (mp_subdir)
- append_dir_subtitles(global, &slist, &n, bstr0(mp_subdir), fname, 1);
- talloc_free(mp_subdir);
- }
+ if (opts->audiofile_auto >= 0)
+ load_paths(global, &slist, &n, fname, opts->audiofile_paths, "audio/");
// Sort by name for filter_subidx()
qsort(slist, n, sizeof(*slist), compare_sub_filename);