Option to switch off album art or to prefer file over embedded

Large embedded album art can cause pauses during
playback or when skipping between tracks, especially
on older devices, but embedded art is currently loaded
even when separately stored smaller image files would be
available.

A workaround is to remove large album art from the
metadata of files.

This now adds a setting to either turn off loading of
album art completely, or to prefer loading the album art
from a separate image file and thus ignore the embedded
versions.

Change-Id: I22fb581abf56072e35e6c29d72e553747ec1a96a
This commit is contained in:
Christian Soffke 2021-11-19 05:11:13 +01:00 committed by William Wilgus
parent aafe2dd2d1
commit bc5a638594
11 changed files with 153 additions and 6 deletions

View file

@ -172,6 +172,8 @@ static struct mutex id3_mutex SHAREDBSS_ATTR; /* (A,O)*/
#define MAX_MULTIPLE_AA SKINNABLE_SCREENS_COUNT
#ifdef HAVE_ALBUMART
static int albumart_mode = -1;
static struct albumart_slot
{
struct dim dim; /* Holds width, height of the albumart */
@ -1690,6 +1692,15 @@ static bool audio_load_cuesheet(struct track_info *infop,
}
#ifdef HAVE_ALBUMART
void set_albumart_mode(int setting)
{
if (albumart_mode != -1 &&
albumart_mode != setting)
playback_update_aa_dims();
albumart_mode = setting;
}
/* Load any album art for the file - returns false if the buffer is full */
static int audio_load_albumart(struct track_info *infop,
struct mp3entry *track_id3)
@ -1709,18 +1720,28 @@ static int audio_load_albumart(struct track_info *infop,
memset(&user_data, 0, sizeof(user_data));
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))
{
user_data.embedded_albumart = NULL;
hid = bufopen(path, 0, TYPE_BITMAP, &user_data);
}
/* We can only decode jpeg for embedded AA */
if (track_id3->has_embedded_albumart && track_id3->albumart.type == AA_TYPE_JPG)
if (global_settings.album_art != AA_OFF &&
hid < 0 && hid != ERR_BUFFER_FULL &&
track_id3->has_embedded_albumart && track_id3->albumart.type == AA_TYPE_JPG)
{
user_data.embedded_albumart = &track_id3->albumart;
hid = bufopen(track_id3->path, 0, TYPE_BITMAP, &user_data);
}
if (hid < 0 && hid != ERR_BUFFER_FULL)
if (global_settings.album_art != AA_OFF &&
hid < 0 && hid != ERR_BUFFER_FULL)
{
/* No embedded AA or it couldn't be loaded - try other sources */
char path[MAX_PATH];
if (find_albumart(track_id3, path, sizeof(path),
&albumart_slots[i].dim))
{