diff options
author | Christian Soffke <christian.soffke@gmail.com> | 2022-05-14 16:18:35 +0200 |
---|---|---|
committer | Aidan MacDonald <amachronic@protonmail.com> | 2022-05-22 06:55:58 -0400 |
commit | cade488b089667f1252220d6b613c6795f960852 (patch) | |
tree | 25030c1876e941f1d9712b1a5fd5e6ee3774b5a2 | |
parent | b357585852d5a43e0399f13f80ec5474d7e67e63 (diff) | |
download | rockbox-cade488b08.tar.gz rockbox-cade488b08.zip |
pictureflow: Fix 'Update Cache' function and update manual
The artwork cache was previously always rebuilt,
even if you had selected the option to update.
"Preparing artwork" should be much quicker now
after a database update.
Change-Id: Ie81486e29d596b52afd21b01ba54c73f1b402be2
-rw-r--r-- | apps/plugins/pictureflow/pictureflow.c | 36 | ||||
-rw-r--r-- | manual/plugins/pictureflow.tex | 7 |
2 files changed, 23 insertions, 20 deletions
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index 38f24732de..2f075a7e61 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c @@ -268,7 +268,6 @@ typedef fb_data pix_t; /* some magic numbers for cache_version. */ #define CACHE_REBUILD 0 -#define CACHE_UPDATE 1 /* Error return values */ #define SUCCESS 0 @@ -306,6 +305,8 @@ struct pf_config_t bool resize; bool show_fps; + + bool update_albumart; }; struct pf_index_t { @@ -511,6 +512,7 @@ static struct configdata config[] = { TYPE_ENUM, 0, 2, { .int_p = &pf_cfg.year_sort_order }, "year order", year_sort_order_conf }, { TYPE_BOOL, 0, 1, { .bool_p = &pf_cfg.show_year }, "show year", NULL }, + { TYPE_BOOL, 0, 1, { .bool_p = &pf_cfg.update_albumart }, "update albumart", NULL } }; #define CONFIG_NUM_ITEMS (sizeof(config) / sizeof(struct configdata)) @@ -667,9 +669,10 @@ static bool confirm_quit(void) return true; } -static void config_save(int cache_version) +static void config_save(int cache_version, bool update_albumart) { pf_cfg.cache_version = cache_version; + pf_cfg.update_albumart = update_albumart; configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION); } @@ -684,12 +687,13 @@ static void config_set_defaults(struct pf_config_t *cfg) cfg->last_album = 0; cfg->backlight_mode = 0; cfg->resize = true; - cfg->cache_version = 0; + cfg->cache_version = CACHE_REBUILD; cfg->show_album_name = (LCD_HEIGHT > 100) ? ALBUM_NAME_TOP : ALBUM_NAME_BOTTOM; cfg->sort_albums_by = SORT_BY_ARTIST_AND_NAME; cfg->year_sort_order = ASCENDING; cfg->show_year = false; + cfg->update_albumart = false; } static inline PFreal fmul(PFreal a, PFreal b) @@ -2250,8 +2254,6 @@ static bool incremental_albumart_cache(bool verbose) unsigned int hash_artist, hash_album; unsigned int format = FORMAT_NATIVE; - bool update = (pf_cfg.cache_version == CACHE_UPDATE); - if (pf_cfg.resize) format |= FORMAT_RESIZE|FORMAT_KEEP_ASPECT; @@ -2263,8 +2265,6 @@ static bool incremental_albumart_cache(bool verbose) aa_cache.inspected++; if (aa_cache.idx >= pf_idx.album_ct) { aa_cache.idx = 0; } /* Rollover */ - if (!get_albumart_for_index_from_db(idx, aa_cache.file, sizeof(aa_cache.file))) - goto aa_failure; //rb->strcpy(aa_cache.file, EMPTY_SLIDE_BMP); hash_artist = mfnv(get_album_artist(idx)); hash_album = mfnv(get_album_name(idx)); @@ -2272,13 +2272,15 @@ static bool incremental_albumart_cache(bool verbose) rb->snprintf(aa_cache.pfraw_file, sizeof(aa_cache.pfraw_file), CACHE_PREFIX "/%x%x.pfraw", hash_album, hash_artist); - if(rb->file_exists(aa_cache.pfraw_file)) { - if(update) { - aa_cache.slides++; - goto aa_success; - } + if(pf_cfg.update_albumart && rb->file_exists(aa_cache.pfraw_file)) { + aa_cache.slides++; + goto aa_success; } + if (!get_albumart_for_index_from_db(idx, aa_cache.file, sizeof(aa_cache.file))) + goto aa_failure; //rb->strcpy(aa_cache.file, EMPTY_SLIDE_BMP); + + aa_cache.input_bmp.data = aa_cache.buf; aa_cache.input_bmp.width = DISPLAY_WIDTH; aa_cache.input_bmp.height = DISPLAY_HEIGHT; @@ -3609,6 +3611,7 @@ static int settings_menu(void) break; /* fallthrough if changed, since cache needs to be rebuilt */ case 10: + pf_cfg.update_albumart = false; pf_cfg.cache_version = CACHE_REBUILD; rb->remove(EMPTY_SLIDE); configfile_save(CONFIG_FILE, config, @@ -3616,7 +3619,8 @@ static int settings_menu(void) rb->splash(HZ, ID2P(LANG_CACHE_REBUILT_NEXT_RESTART)); break; case 11: - pf_cfg.cache_version = CACHE_UPDATE; + pf_cfg.update_albumart = true; + pf_cfg.cache_version = CACHE_REBUILD; rb->remove(EMPTY_SLIDE); configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION); @@ -4319,13 +4323,13 @@ static int pictureflow_main(const char* selected_file) pf_idx.buf_sz -= aa_bufsz; if (!create_empty_slide(pf_cfg.cache_version != CACHE_VERSION)) { - config_save(CACHE_REBUILD); + config_save(CACHE_REBUILD, false); error_wait("Could not load the empty slide"); return PLUGIN_ERROR; } if ((pf_cfg.cache_version != CACHE_VERSION) && !create_albumart_cache()) { - config_save(CACHE_REBUILD); + config_save(CACHE_REBUILD, false); error_wait("Could not create album art cache"); } else if(aa_cache.inspected < pf_idx.album_ct) { rb->splash(HZ * 2, "Updating album art cache in background"); @@ -4333,7 +4337,7 @@ static int pictureflow_main(const char* selected_file) if (pf_cfg.cache_version != CACHE_VERSION) { - config_save(CACHE_VERSION); + config_save(CACHE_VERSION, pf_cfg.update_albumart); } rb->buflib_init(&buf_ctx, (void *)pf_idx.buf, pf_idx.buf_sz); diff --git a/manual/plugins/pictureflow.tex b/manual/plugins/pictureflow.tex index 1fb9f28c29..2c83a3941f 100644 --- a/manual/plugins/pictureflow.tex +++ b/manual/plugins/pictureflow.tex @@ -221,10 +221,9 @@ reduces the time it takes for cover art to be displayed.}} \item[Zoom.] Changes the distance at which slides are rendered from the ``camera''. \item[Resize Covers.] Set whether to automatically resize the covers or to leave them at their original size. - \item[Rebuild cache.] Rebuild the PictureFlow cache. This is needed in order - for PictureFlow to pick up new albums, and may occasionally be needed if albums - are removed. - \item[Update cache.] Update the PictureFlow cache. New albumart will be added. + \item[Rebuild cache.] Creates a fresh album index and builds the artwork cache from scratch. + \item[Update cache.] Creates a fresh album index and updates the existing artwork cache to + include newly added albums. \item[WPS integration.] Integrate PictureFlow with the While Playing Screen and enable the Current Playlist context menu. \item[Backlight.] Force backlight on while running pictureflow. |