From 73be20143eea2c0232b63c2617e8604a44217e57 Mon Sep 17 00:00:00 2001 From: sfan5 Date: Wed, 28 Oct 2020 18:15:34 +0100 Subject: player: fix external cover file prioritization Array order was ignored entirely instead of being used as intended. Fixes: c07089a250 --- player/external_files.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'player') 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); -- cgit v1.2.3