From bc5a6385949c9f0a17173f3512aa9a6db9175803 Mon Sep 17 00:00:00 2001 From: Christian Soffke Date: Fri, 19 Nov 2021 05:11:13 +0100 Subject: 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 --- apps/gui/quickscreen.c | 10 +++++++ apps/lang/english.lang | 42 +++++++++++++++++++++++++++ apps/menus/playback_menu.c | 25 ++++++++++++++++ apps/playback.c | 29 +++++++++++++++--- apps/playback.h | 3 ++ apps/settings.c | 3 ++ apps/settings.h | 14 ++++++++- apps/settings_list.c | 10 +++++++ apps/shortcuts.c | 11 ++++++- manual/appendix/config_file_options.tex | 4 +++ manual/configure_rockbox/playback_options.tex | 8 +++++ 11 files changed, 153 insertions(+), 6 deletions(-) diff --git a/apps/gui/quickscreen.c b/apps/gui/quickscreen.c index b2f5050ab3..a7d07f4e33 100644 --- a/apps/gui/quickscreen.c +++ b/apps/gui/quickscreen.c @@ -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); } diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 86d1dc5daf..43d73a8445 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang @@ -16187,3 +16187,45 @@ *: "Descending" + + id: LANG_ALBUM_ART + desc: in Settings + user: core + + *: "Album Art" + + + *: "Album Art" + + + *: "Album Art" + + + + id: LANG_PREFER_EMBEDDED + desc: in Settings + user: core + + *: "Prefer Embedded" + + + *: "Prefer Embedded" + + + *: "Prefer Embedded" + + + + id: LANG_PREFER_IMAGE_FILE + desc: in Settings + user: core + + *: "Prefer Image File" + + + *: "Prefer Image File" + + + *: "Prefer Image File" + + diff --git a/apps/menus/playback_menu.c b/apps/menus/playback_menu.c index 5f9479fae3..fe319d6027 100644 --- a/apps/menus/playback_menu.c +++ b/apps/menus/playback_menu.c @@ -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 ); diff --git a/apps/playback.c b/apps/playback.c index 4162d9b647..cac28bd6e7 100644 --- a/apps/playback.c +++ b/apps/playback.c @@ -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)) { diff --git a/apps/playback.h b/apps/playback.h index a87ef873d0..b9aa413ef3 100644 --- a/apps/playback.h +++ b/apps/playback.h @@ -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); diff --git a/apps/settings.c b/apps/settings.c index 6d49beb5e3..566573ae68 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -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 */ diff --git a/apps/settings.h b/apps/settings.h index b3c31476e3..936280ba5a 100644 --- a/apps/settings.h +++ b/apps/settings.h @@ -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 */ diff --git a/apps/settings_list.c b/apps/settings_list.c index 795d42ceba..7b24db22e5 100644 --- a/apps/settings_list.c +++ b/apps/settings_list.c @@ -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 */ diff --git a/apps/shortcuts.c b/apps/shortcuts.c index b0a949933c..9f042a926a 100644 --- a/apps/shortcuts.c +++ b/apps/shortcuts.c @@ -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); diff --git a/manual/appendix/config_file_options.tex b/manual/appendix/config_file_options.tex index b7e807baf4..09bc148535 100644 --- a/manual/appendix/config_file_options.tex +++ b/manual/appendix/config_file_options.tex @@ -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\\ diff --git a/manual/configure_rockbox/playback_options.tex b/manual/configure_rockbox/playback_options.tex index 6c8f5de316..2619125e5e 100644 --- a/manual/configure_rockbox/playback_options.tex +++ b/manual/configure_rockbox/playback_options.tex @@ -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. +} \ No newline at end of file -- cgit