From 6f0fd91343afbd0268cd3027f6a56371721295a3 Mon Sep 17 00:00:00 2001 From: William Wilgus Date: Thu, 25 Jun 2020 18:16:44 -0400 Subject: [PATCH] Pictureflow Fixes: Sansa C200 Sansa C200 fix Change-Id: I548b7142dde9ea4da5455686bed650aa40c9c90a --- apps/plugins/pictureflow/pictureflow.c | 30 ++++++++++++++++++-------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index 3ccfc0d3a2..045596ce5a 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c @@ -36,12 +36,16 @@ - /* Capacity 10 000 entries (for example 10k different albums) */ #if PLUGIN_BUFFER_SIZE > 0x10000 #define UNIQBUF_SIZE (64*1024) -#else /*Bugfix -- Several players havent enough Ram to allow such a large buffer */ - #define UNIQBUF_SIZE (16*1024) +#else + #if PLUGIN_BUFFER_SIZE > 0x8000 + /*Bugfix -- Several players havent enough Ram to allow such a large buffer */ + #define UNIQBUF_SIZE (16*1024) + #else + #define UNIQBUF_SIZE 0 + #endif #endif static long uniqbuf[UNIQBUF_SIZE / sizeof(long)]; @@ -904,8 +908,12 @@ static int create_album_index(void) artist_seek = artist[j].seek; rb->memset(&tcs, 0, sizeof(struct tagcache_search) ); rb->tagcache_search(&tcs, tag_album); - /* Prevent duplicate entries in the search list. */ +#if UNIQBUF_SIZE > 0 + /* Prevent duplicate entries in the search list. */ rb->tagcache_search_set_uniqbuf(&tcs, uniqbuf, UNIQBUF_SIZE); +#else + (void) uniqbuf; +#endif rb->tagcache_search_add_filter(&tcs, tag_albumartist, artist_seek); while (rb->tagcache_get_next(&tcs)) { @@ -942,7 +950,7 @@ static int create_album_index(void) static int save_album_index(void){ int fd; - fd = rb->creat(PLUGIN_DIR "/demos/album_ndx.tmp",0666); + fd = rb->creat(CACHE_PREFIX PLUGIN_DEMOS_DATA_DIR "/album_ndx.tmp",0666); if(fd >= 0) { int unsigned_size = sizeof(unsigned int); @@ -965,7 +973,7 @@ static int save_album_index(void){ /*Loads the artists+albums index information stored in the hard drive*/ static int load_album_index(void){ - int fr = rb->open(PLUGIN_DIR "/demos/album_ndx.tmp", O_RDONLY); + int fr = rb->open(CACHE_PREFIX PLUGIN_DEMOS_DATA_DIR "/album_ndx.tmp", O_RDONLY); if (fr >= 0){ int unsigned_size = sizeof(unsigned int); int int_size = sizeof(int); @@ -1041,7 +1049,8 @@ static int get_wps_current_index(void) for( i=0; i < album_count; i++ ) { if(!rb->strcmp(album_names + album[i].name_idx, id3->album) && - !rb->strcmp(artist_names + artist[album[i].artist_idx].name_idx, id3->albumartist)) + !rb->strcmp(artist_names + artist[album[i].artist_idx].name_idx, + id3->albumartist)) return i; } } @@ -1071,7 +1080,9 @@ static void create_track_index(const int slide_index) goto fail; rb->tagcache_search_add_filter(&tcs, tag_album, album[slide_index].seek); - rb->tagcache_search_add_filter(&tcs, tag_albumartist, artist[album[slide_index].artist_idx].seek); + rb->tagcache_search_add_filter(&tcs, tag_albumartist, + artist[album[slide_index].artist_idx].seek); + track_count=0; int string_index = 0, track_num; int disc_num; @@ -1187,7 +1198,8 @@ static bool get_albumart_for_index_from_db(const int slide_index, char *buf, bool result; /* find the first track of the album */ rb->tagcache_search_add_filter(&tcs, tag_album, album[slide_index].seek); - rb->tagcache_search_add_filter(&tcs, tag_albumartist, artist[album[slide_index].artist_idx].seek); + rb->tagcache_search_add_filter(&tcs, tag_albumartist, + artist[album[slide_index].artist_idx].seek); if ( rb->tagcache_get_next(&tcs) ) { struct mp3entry id3;