summaryrefslogtreecommitdiff
path: root/apps/plugins/pictureflow/pictureflow.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pictureflow/pictureflow.c')
-rw-r--r--apps/plugins/pictureflow/pictureflow.c36
1 files changed, 20 insertions, 16 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;
268 268
269/* some magic numbers for cache_version. */ 269/* some magic numbers for cache_version. */
270#define CACHE_REBUILD 0 270#define CACHE_REBUILD 0
271#define CACHE_UPDATE 1
272 271
273/* Error return values */ 272/* Error return values */
274#define SUCCESS 0 273#define SUCCESS 0
@@ -306,6 +305,8 @@ struct pf_config_t
306 305
307 bool resize; 306 bool resize;
308 bool show_fps; 307 bool show_fps;
308
309 bool update_albumart;
309}; 310};
310 311
311struct pf_index_t { 312struct pf_index_t {
@@ -511,6 +512,7 @@ static struct configdata config[] =
511 { TYPE_ENUM, 0, 2, { .int_p = &pf_cfg.year_sort_order }, "year order", 512 { TYPE_ENUM, 0, 2, { .int_p = &pf_cfg.year_sort_order }, "year order",
512 year_sort_order_conf }, 513 year_sort_order_conf },
513 { TYPE_BOOL, 0, 1, { .bool_p = &pf_cfg.show_year }, "show year", NULL }, 514 { TYPE_BOOL, 0, 1, { .bool_p = &pf_cfg.show_year }, "show year", NULL },
515 { TYPE_BOOL, 0, 1, { .bool_p = &pf_cfg.update_albumart }, "update albumart", NULL }
514}; 516};
515 517
516#define CONFIG_NUM_ITEMS (sizeof(config) / sizeof(struct configdata)) 518#define CONFIG_NUM_ITEMS (sizeof(config) / sizeof(struct configdata))
@@ -667,9 +669,10 @@ static bool confirm_quit(void)
667 return true; 669 return true;
668} 670}
669 671
670static void config_save(int cache_version) 672static void config_save(int cache_version, bool update_albumart)
671{ 673{
672 pf_cfg.cache_version = cache_version; 674 pf_cfg.cache_version = cache_version;
675 pf_cfg.update_albumart = update_albumart;
673 configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION); 676 configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION);
674} 677}
675 678
@@ -684,12 +687,13 @@ static void config_set_defaults(struct pf_config_t *cfg)
684 cfg->last_album = 0; 687 cfg->last_album = 0;
685 cfg->backlight_mode = 0; 688 cfg->backlight_mode = 0;
686 cfg->resize = true; 689 cfg->resize = true;
687 cfg->cache_version = 0; 690 cfg->cache_version = CACHE_REBUILD;
688 cfg->show_album_name = (LCD_HEIGHT > 100) 691 cfg->show_album_name = (LCD_HEIGHT > 100)
689 ? ALBUM_NAME_TOP : ALBUM_NAME_BOTTOM; 692 ? ALBUM_NAME_TOP : ALBUM_NAME_BOTTOM;
690 cfg->sort_albums_by = SORT_BY_ARTIST_AND_NAME; 693 cfg->sort_albums_by = SORT_BY_ARTIST_AND_NAME;
691 cfg->year_sort_order = ASCENDING; 694 cfg->year_sort_order = ASCENDING;
692 cfg->show_year = false; 695 cfg->show_year = false;
696 cfg->update_albumart = false;
693} 697}
694 698
695static inline PFreal fmul(PFreal a, PFreal b) 699static inline PFreal fmul(PFreal a, PFreal b)
@@ -2250,8 +2254,6 @@ static bool incremental_albumart_cache(bool verbose)
2250 unsigned int hash_artist, hash_album; 2254 unsigned int hash_artist, hash_album;
2251 unsigned int format = FORMAT_NATIVE; 2255 unsigned int format = FORMAT_NATIVE;
2252 2256
2253 bool update = (pf_cfg.cache_version == CACHE_UPDATE);
2254
2255 if (pf_cfg.resize) 2257 if (pf_cfg.resize)
2256 format |= FORMAT_RESIZE|FORMAT_KEEP_ASPECT; 2258 format |= FORMAT_RESIZE|FORMAT_KEEP_ASPECT;
2257 2259
@@ -2263,8 +2265,6 @@ static bool incremental_albumart_cache(bool verbose)
2263 aa_cache.inspected++; 2265 aa_cache.inspected++;
2264 if (aa_cache.idx >= pf_idx.album_ct) { aa_cache.idx = 0; } /* Rollover */ 2266 if (aa_cache.idx >= pf_idx.album_ct) { aa_cache.idx = 0; } /* Rollover */
2265 2267
2266 if (!get_albumart_for_index_from_db(idx, aa_cache.file, sizeof(aa_cache.file)))
2267 goto aa_failure; //rb->strcpy(aa_cache.file, EMPTY_SLIDE_BMP);
2268 2268
2269 hash_artist = mfnv(get_album_artist(idx)); 2269 hash_artist = mfnv(get_album_artist(idx));
2270 hash_album = mfnv(get_album_name(idx)); 2270 hash_album = mfnv(get_album_name(idx));
@@ -2272,13 +2272,15 @@ static bool incremental_albumart_cache(bool verbose)
2272 rb->snprintf(aa_cache.pfraw_file, sizeof(aa_cache.pfraw_file), 2272 rb->snprintf(aa_cache.pfraw_file, sizeof(aa_cache.pfraw_file),
2273 CACHE_PREFIX "/%x%x.pfraw", hash_album, hash_artist); 2273 CACHE_PREFIX "/%x%x.pfraw", hash_album, hash_artist);
2274 2274
2275 if(rb->file_exists(aa_cache.pfraw_file)) { 2275 if(pf_cfg.update_albumart && rb->file_exists(aa_cache.pfraw_file)) {
2276 if(update) { 2276 aa_cache.slides++;
2277 aa_cache.slides++; 2277 goto aa_success;
2278 goto aa_success;
2279 }
2280 } 2278 }
2281 2279
2280 if (!get_albumart_for_index_from_db(idx, aa_cache.file, sizeof(aa_cache.file)))
2281 goto aa_failure; //rb->strcpy(aa_cache.file, EMPTY_SLIDE_BMP);
2282
2283
2282 aa_cache.input_bmp.data = aa_cache.buf; 2284 aa_cache.input_bmp.data = aa_cache.buf;
2283 aa_cache.input_bmp.width = DISPLAY_WIDTH; 2285 aa_cache.input_bmp.width = DISPLAY_WIDTH;
2284 aa_cache.input_bmp.height = DISPLAY_HEIGHT; 2286 aa_cache.input_bmp.height = DISPLAY_HEIGHT;
@@ -3609,6 +3611,7 @@ static int settings_menu(void)
3609 break; 3611 break;
3610 /* fallthrough if changed, since cache needs to be rebuilt */ 3612 /* fallthrough if changed, since cache needs to be rebuilt */
3611 case 10: 3613 case 10:
3614 pf_cfg.update_albumart = false;
3612 pf_cfg.cache_version = CACHE_REBUILD; 3615 pf_cfg.cache_version = CACHE_REBUILD;
3613 rb->remove(EMPTY_SLIDE); 3616 rb->remove(EMPTY_SLIDE);
3614 configfile_save(CONFIG_FILE, config, 3617 configfile_save(CONFIG_FILE, config,
@@ -3616,7 +3619,8 @@ static int settings_menu(void)
3616 rb->splash(HZ, ID2P(LANG_CACHE_REBUILT_NEXT_RESTART)); 3619 rb->splash(HZ, ID2P(LANG_CACHE_REBUILT_NEXT_RESTART));
3617 break; 3620 break;
3618 case 11: 3621 case 11:
3619 pf_cfg.cache_version = CACHE_UPDATE; 3622 pf_cfg.update_albumart = true;
3623 pf_cfg.cache_version = CACHE_REBUILD;
3620 rb->remove(EMPTY_SLIDE); 3624 rb->remove(EMPTY_SLIDE);
3621 configfile_save(CONFIG_FILE, config, 3625 configfile_save(CONFIG_FILE, config,
3622 CONFIG_NUM_ITEMS, CONFIG_VERSION); 3626 CONFIG_NUM_ITEMS, CONFIG_VERSION);
@@ -4319,13 +4323,13 @@ static int pictureflow_main(const char* selected_file)
4319 pf_idx.buf_sz -= aa_bufsz; 4323 pf_idx.buf_sz -= aa_bufsz;
4320 4324
4321 if (!create_empty_slide(pf_cfg.cache_version != CACHE_VERSION)) { 4325 if (!create_empty_slide(pf_cfg.cache_version != CACHE_VERSION)) {
4322 config_save(CACHE_REBUILD); 4326 config_save(CACHE_REBUILD, false);
4323 error_wait("Could not load the empty slide"); 4327 error_wait("Could not load the empty slide");
4324 return PLUGIN_ERROR; 4328 return PLUGIN_ERROR;
4325 } 4329 }
4326 4330
4327 if ((pf_cfg.cache_version != CACHE_VERSION) && !create_albumart_cache()) { 4331 if ((pf_cfg.cache_version != CACHE_VERSION) && !create_albumart_cache()) {
4328 config_save(CACHE_REBUILD); 4332 config_save(CACHE_REBUILD, false);
4329 error_wait("Could not create album art cache"); 4333 error_wait("Could not create album art cache");
4330 } else if(aa_cache.inspected < pf_idx.album_ct) { 4334 } else if(aa_cache.inspected < pf_idx.album_ct) {
4331 rb->splash(HZ * 2, "Updating album art cache in background"); 4335 rb->splash(HZ * 2, "Updating album art cache in background");
@@ -4333,7 +4337,7 @@ static int pictureflow_main(const char* selected_file)
4333 4337
4334 if (pf_cfg.cache_version != CACHE_VERSION) 4338 if (pf_cfg.cache_version != CACHE_VERSION)
4335 { 4339 {
4336 config_save(CACHE_VERSION); 4340 config_save(CACHE_VERSION, pf_cfg.update_albumart);
4337 } 4341 }
4338 4342
4339 rb->buflib_init(&buf_ctx, (void *)pf_idx.buf, pf_idx.buf_sz); 4343 rb->buflib_init(&buf_ctx, (void *)pf_idx.buf, pf_idx.buf_sz);