diff options
author | sfan5 <sfan5@live.de> | 2020-10-28 18:15:34 +0100 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2020-10-28 18:15:34 +0100 |
commit | 73be20143eea2c0232b63c2617e8604a44217e57 (patch) | |
tree | d422de4ef0509e57c5c01ad7c4fb83377df5aaea | |
parent | b4d9980870941812b152a6fe66caf867a11211bb (diff) | |
download | mpv-73be20143eea2c0232b63c2617e8604a44217e57.tar.bz2 mpv-73be20143eea2c0232b63c2617e8604a44217e57.tar.xz |
player: fix external cover file prioritization
Array order was ignored entirely instead of being used as intended.
Fixes: c07089a250
-rw-r--r-- | player/external_files.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/player/external_files.c b/player/external_files.c index e42558f594..06585bf18f 100644 --- a/player/external_files.c +++ b/player/external_files.c @@ -43,6 +43,7 @@ static const char *const audio_exts[] = {"mp3", "aac", "mka", "dts", "flac", NULL}; // Stolen from: vlc/-/blob/master/modules/meta_engine/folder.c#L40 +// sorted by priority (descending) static const char *const cover_files[] = { "AlbumArt.jpg", "Album.jpg", @@ -81,11 +82,13 @@ static int test_ext(bstr ext) return -1; } -static int test_filename(bstr fname) +static int test_cover_filename(bstr fname, int *priority) { for (int n = 0; cover_files[n]; n++) { - if (bstrcasecmp(bstr0(cover_files[n]), fname) == 0) + if (bstrcasecmp(bstr0(cover_files[n]), fname) == 0) { + *priority = MP_ARRAY_SIZE(cover_files) - n; return STREAM_VIDEO; + } } return -1; } @@ -188,9 +191,10 @@ static void append_dir_subtitles(struct mpv_global *global, struct MPOpts *opts, talloc_steal(tmpmem2, dename.start); // check what it is (most likely) + int cover_prio = 0; int type = test_ext(tmp_fname_ext); if (type < 0) - type = test_filename(dename); + type = test_cover_filename(dename, &cover_prio); char **langs = NULL; int fuzz = -1; switch (type) { @@ -247,7 +251,7 @@ static void append_dir_subtitles(struct mpv_global *global, struct MPOpts *opts, // cover art: just accept it if (type == STREAM_VIDEO && fuzz >= 1) - prio |= 1; + prio = cover_prio; mp_dbg(log, "Potential external file: \"%s\" Priority: %d\n", de->d_name, prio); |