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.
This commit is contained in:
wm4
2015-02-05 22:14:17 +01:00
parent 3b5d7d1a1c
commit cfd3d5b520
3 changed files with 16 additions and 4 deletions

View File

@@ -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);
}