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

@ -39,6 +39,9 @@
#include "option_select.h"
#include "debug.h"
#include "shortcuts.h"
#ifdef HAVE_ALBUMART
#include "playback.h"
#endif
/* 1 top, 1 bottom, 2 on either side, 1 for the icons
* if enough space, top and bottom have 2 lines */
@ -411,6 +414,9 @@ int quick_screen_quick(int button_enter)
struct gui_quickscreen qs;
bool oldshuffle = global_settings.playlist_shuffle;
int oldrepeat = global_settings.repeat_mode;
#ifdef HAVE_ALBUMART
int old_album_art = global_settings.album_art;
#endif
bool usb = false;
if (global_settings.shortcuts_replaces_qs)
@ -446,6 +452,10 @@ int quick_screen_quick(int button_enter)
else
playlist_sort(NULL, true);
}
#ifdef HAVE_ALBUMART
if (old_album_art != global_settings.album_art)
set_albumart_mode(global_settings.album_art);
#endif
}
return (usb ? 1:0);
}

View file

@ -16187,3 +16187,45 @@
*: "Descending"
</voice>
</phrase>
<phrase>
id: LANG_ALBUM_ART
desc: in Settings
user: core
<source>
*: "Album Art"
</source>
<dest>
*: "Album Art"
</dest>
<voice>
*: "Album Art"
</voice>
</phrase>
<phrase>
id: LANG_PREFER_EMBEDDED
desc: in Settings
user: core
<source>
*: "Prefer Embedded"
</source>
<dest>
*: "Prefer Embedded"
</dest>
<voice>
*: "Prefer Embedded"
</voice>
</phrase>
<phrase>
id: LANG_PREFER_IMAGE_FILE
desc: in Settings
user: core
<source>
*: "Prefer Image File"
</source>
<dest>
*: "Prefer Image File"
</dest>
<voice>
*: "Prefer Image File"
</voice>
</phrase>

View file

@ -201,6 +201,28 @@ MENUITEM_SETTING(pause_rewind, &global_settings.pause_rewind, NULL);
MENUITEM_SETTING(play_frequency, &global_settings.play_frequency,
playback_callback);
#endif
#ifdef HAVE_ALBUMART
static int albumart_callback(int action,
const struct menu_item_ex *this_item,
struct gui_synclist *this_list)
{
(void)this_item;
(void)this_list;
static int initial_aa_setting;
switch (action)
{
case ACTION_ENTER_MENUITEM:
initial_aa_setting = global_settings.album_art;
break;
case ACTION_EXIT_MENUITEM: /* on exit */
if (initial_aa_setting != global_settings.album_art)
set_albumart_mode(global_settings.album_art);
}
return action;
}
MENUITEM_SETTING(album_art, &global_settings.album_art,
albumart_callback);
#endif
MAKE_MENU(playback_settings,ID2P(LANG_PLAYBACK),0,
Icon_Playback_menu,
@ -230,6 +252,9 @@ MAKE_MENU(playback_settings,ID2P(LANG_PLAYBACK),0,
,&pause_rewind
#ifdef HAVE_PLAY_FREQ
,&play_frequency
#endif
#ifdef HAVE_ALBUMART
,&album_art
#endif
);

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))
{

View file

@ -85,6 +85,9 @@ void audio_set_crossfade(int enable);
#ifdef HAVE_PLAY_FREQ
void audio_set_playback_frequency(int setting);
#endif
#ifdef HAVE_ALBUMART
void set_albumart_mode(int setting);
#endif
size_t audio_get_filebuflen(void);

View file

@ -945,6 +945,9 @@ void settings_apply(bool read_disk)
lcd_bidir_scroll(global_settings.bidir_limit);
lcd_scroll_delay(global_settings.scroll_delay);
#ifdef HAVE_ALBUMART
set_albumart_mode(global_settings.album_art);
#endif
#ifdef HAVE_PLAY_FREQ
/* before crossfade */

View file

@ -127,6 +127,15 @@ enum
QUEUE_SHOW_IN_SUBMENU
};
#ifdef HAVE_ALBUMART
enum
{
AA_OFF = 0,
AA_PREFER_EMBEDDED,
AA_PREFER_IMAGE_FILE
};
#endif
/* dir filter options */
/* Note: Any new filter modes need to be added before NUM_FILTER_MODES.
* Any new rockbox browse filter modes (accessible through the menu)
@ -598,7 +607,10 @@ struct user_settings
bool warnon_erase_dynplaylist; /* warn when erasing dynamic playlist */
bool show_shuffled_adding_options; /* whether to display options for adding shuffled tracks to dynamic playlist */
int show_queue_options; /* how and whether to display options to queue tracks */
#ifdef HAVE_ALBUMART
int album_art; /* switch off album art display or choose preferred source */
#endif
/* playlist viewer settings */
bool playlist_viewer_icons; /* display icons on viewer */
bool playlist_viewer_indices; /* display playlist indices on viewer */

View file

@ -927,6 +927,16 @@ const struct settings_list settings[] = {
#error "HAVE_PLAY_FREQ < 48???"
#endif
#endif /* HAVE_PLAY_FREQ */
#ifdef HAVE_ALBUMART
CHOICE_SETTING(0, album_art, LANG_ALBUM_ART, 1,
"album art", "off,prefer embedded,prefer image file",
NULL, 3,
ID2P(LANG_OFF),
ID2P(LANG_PREFER_EMBEDDED),
ID2P(LANG_PREFER_IMAGE_FILE)),
#endif
/* LCD */
#ifdef HAVE_LCD_CONTRAST
/* its easier to leave this one un-macro()ed for the time being */

View file

@ -47,7 +47,9 @@
#include "screens.h"
#include "talk.h"
#include "yesno.h"
#ifdef HAVE_ALBUMART
#include "playback.h"
#endif
#define MAX_SHORTCUT_NAME 32
#define SHORTCUTS_FILENAME ROCKBOX_DIR "/shortcuts.txt"
@ -661,9 +663,16 @@ int do_shortcut_menu(void *ignored)
case SHORTCUT_SETTING:
{
int old_sleeptimer_duration = global_settings.sleeptimer_duration;
#ifdef HAVE_ALBUMART
int old_album_art = global_settings.album_art;
#endif
do_setting_screen(sc->u.setting,
sc->name[0] ? sc->name : P2STR(ID2P(sc->u.setting->lang_id)),NULL);
#ifdef HAVE_ALBUMART
if (old_album_art != global_settings.album_art)
set_albumart_mode(global_settings.album_art);
#endif
if (old_sleeptimer_duration != global_settings.sleeptimer_duration &&
get_sleep_timer())
set_sleeptimer_duration(global_settings.sleeptimer_duration);

View file

@ -132,6 +132,10 @@
rewind duration on pause & 0 to 15 & s\\
disable autoresume if phones not present & off, on & N/A\\
Last.fm Logging & off, on & N/A\\
\opt{albumart}{
album art
& off, prefer embedded, prefer image file & N/A\\
}
talk dir & off, number, spell& N/A\\
talk dir clip & off, on & N/A\\
talk file & off, number, spell& N/A\\

View file

@ -324,3 +324,11 @@ you to configure settings related to audio playback.
your audio. This is typically 44.1kHz.}
\note{Opus files are always 48kHz.}
}
\opt{albumart}{
\section{Album Art}
Album art will not be loaded or displayed when set to \setting{Off}.
To prefer loading album art that is stored in a separate image file, set to
\setting{Prefer Image File}. The default behavior is to
\setting{Prefer Embedded} album art.
}