From 4d7327b04d8e5384973185cc649a56e2779be714 Mon Sep 17 00:00:00 2001 From: Christian Soffke Date: Tue, 12 Apr 2022 17:54:37 +0200 Subject: Album Art: Eliminate redundant check When the 'Album Art' setting was set to 'Prefer Image File' and neither image file nor embedded artwork were found, playback would check for files twice. Change-Id: Ibe392928d58ec04103e2572124841724509bd859 --- apps/playback.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'apps') diff --git a/apps/playback.c b/apps/playback.c index 59d70842ee..a56c6d17ec 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -1710,6 +1710,7 @@ static int audio_load_albumart(struct track_info *infop, struct bufopen_bitmap_data user_data; int *aa_hid = &infop->aa_hid[i]; int hid = ERR_UNSUPPORTED_TYPE; + bool checked_image_file = false; /* albumart_slots may change during a yield of bufopen, * but that's no problem */ @@ -1721,12 +1722,15 @@ static int audio_load_albumart(struct track_info *infop, user_data.dim = &albumart_slots[i].dim; char path[MAX_PATH]; - if(global_settings.album_art == AA_PREFER_IMAGE_FILE && - find_albumart(track_id3, path, sizeof(path), - &albumart_slots[i].dim)) + if(global_settings.album_art == AA_PREFER_IMAGE_FILE) { + if (find_albumart(track_id3, path, sizeof(path), + &albumart_slots[i].dim)) + { user_data.embedded_albumart = NULL; hid = bufopen(path, 0, TYPE_BITMAP, &user_data); + } + checked_image_file = true; } /* We can only decode jpeg for embedded AA */ @@ -1738,7 +1742,7 @@ static int audio_load_albumart(struct track_info *infop, hid = bufopen(track_id3->path, 0, TYPE_BITMAP, &user_data); } - if (global_settings.album_art != AA_OFF && + if (global_settings.album_art != AA_OFF && !checked_image_file && hid < 0 && hid != ERR_BUFFER_FULL) { /* No embedded AA or it couldn't be loaded - try other sources */ -- cgit v1.2.3