summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-02-05 22:14:17 +0100
committerwm4 <wm4@nowhere>2015-02-05 22:14:17 +0100
commitcfd3d5b52003a23376d02fd6cc581f46289badd2 (patch)
tree1b8ec65d39459b99bd8059f196d146ae04f33d0a
parent3b5d7d1a1c664d15fa35992498ac4568ebc39e3b (diff)
downloadmpv-cfd3d5b52003a23376d02fd6cc581f46289badd2.tar.bz2
mpv-cfd3d5b52003a23376d02fd6cc581f46289badd2.tar.xz
player: do not autoload audio with audio files, enable autoloading
Autoload external audio files only if there's at least a video track (which is not coverart pseudo-video). Enable external audio file autoloading by default. Now that we actively avoid doing stupid things like loading an external audio file for an audio-only file, this should be fine. Additionally, don't autoload subtitles if a subtitle is played. Although you currently can't play subtitles without audio or video, it's disturbing and stupid that the player might load subtitle files with different extension and then fail.
-rw-r--r--DOCS/man/options.rst6
-rw-r--r--options/options.c2
-rw-r--r--player/loadfile.c12
3 files changed, 16 insertions, 4 deletions
diff --git a/DOCS/man/options.rst b/DOCS/man/options.rst
index 852752e5ff..ad73b6ddcf 100644
--- a/DOCS/man/options.rst
+++ b/DOCS/man/options.rst
@@ -1041,11 +1041,11 @@ Audio
``--audio-file-auto=<no|exact|fuzzy|all>``, ``--no-audio-file-auto``
Load additional audio files matching the video filename. The parameter
- specifies how external audio files are matched. This is disabled by
+ specifies how external audio files are matched. ``exact`` is enabled by
default.
- :no: Don't automatically load external audio files (default).
- :exact: Load the media filename with audio file extension.
+ :no: Don't automatically load external audio files.
+ :exact: Load the media filename with audio file extension (default).
:fuzzy: Load all audio files containing media filename.
:all: Load all audio files in the current directory.
diff --git a/options/options.c b/options/options.c
index 6f23f2c499..acc2c99b9e 100644
--- a/options/options.c
+++ b/options/options.c
@@ -764,7 +764,7 @@ const struct MPOpts mp_default_opts = {
.movie_aspect = -1.,
.field_dominance = -1,
.sub_auto = 0,
- .audiofile_auto = -1,
+ .audiofile_auto = 0,
.osd_bar_visible = 1,
#if HAVE_LIBASS
.ass_enabled = 1,
diff --git a/player/loadfile.c b/player/loadfile.c
index 5b67618611..6560fe7806 100644
--- a/player/loadfile.c
+++ b/player/loadfile.c
@@ -737,6 +737,13 @@ static void autoload_external_files(struct MPContext *mpctx)
}
struct subfn *list = find_external_files(mpctx->global, base_filename);
talloc_steal(tmp, list);
+
+ int sc[STREAM_TYPE_COUNT] = {0};
+ for (int n = 0; n < mpctx->num_tracks; n++) {
+ if (!mpctx->tracks[n]->attached_picture)
+ sc[mpctx->tracks[n]->type]++;
+ }
+
for (int i = 0; list && list[i].fname; i++) {
char *filename = list[i].fname;
char *lang = list[i].lang;
@@ -744,6 +751,10 @@ static void autoload_external_files(struct MPContext *mpctx)
if (strcmp(mpctx->sources[n]->stream->url, filename) == 0)
goto skip;
}
+ if (list[i].type == STREAM_SUB && !sc[STREAM_VIDEO] && !sc[STREAM_AUDIO])
+ goto skip;
+ if (list[i].type == STREAM_AUDIO && !sc[STREAM_VIDEO])
+ goto skip;
struct track *track = mp_add_external_file(mpctx, filename, list[i].type);
if (track) {
track->auto_loaded = true;
@@ -752,6 +763,7 @@ static void autoload_external_files(struct MPContext *mpctx)
}
skip:;
}
+
talloc_free(tmp);
}