diff options
Diffstat (limited to 'apps/plugins/pictureflow')
-rw-r--r-- | apps/plugins/pictureflow/pictureflow.c | 263 |
1 files changed, 228 insertions, 35 deletions
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index 0efba4f5cb..d6ab0f3e99 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c | |||
@@ -36,6 +36,11 @@ | |||
36 | 36 | ||
37 | 37 | ||
38 | 38 | ||
39 | |||
40 | /* Capacity 10 000 entries (for example 10k different albums) */ | ||
41 | #define UNIQBUF_SIZE (64*1024) | ||
42 | static long uniqbuf[UNIQBUF_SIZE / sizeof(long)]; | ||
43 | |||
39 | /******************************* Globals ***********************************/ | 44 | /******************************* Globals ***********************************/ |
40 | 45 | ||
41 | /* | 46 | /* |
@@ -254,6 +259,7 @@ typedef fb_data pix_t; | |||
254 | /* Error return values */ | 259 | /* Error return values */ |
255 | #define ERROR_NO_ALBUMS -1 | 260 | #define ERROR_NO_ALBUMS -1 |
256 | #define ERROR_BUFFER_FULL -2 | 261 | #define ERROR_BUFFER_FULL -2 |
262 | #define ERROR_NO_ARTISTS -3 | ||
257 | 263 | ||
258 | /* current version for cover cache */ | 264 | /* current version for cover cache */ |
259 | #define CACHE_VERSION 3 | 265 | #define CACHE_VERSION 3 |
@@ -279,6 +285,12 @@ struct slide_cache { | |||
279 | 285 | ||
280 | struct album_data { | 286 | struct album_data { |
281 | int name_idx; | 287 | int name_idx; |
288 | int artist_idx; | ||
289 | long seek; | ||
290 | }; | ||
291 | |||
292 | struct artist_data { | ||
293 | int name_idx; | ||
282 | long seek; | 294 | long seek; |
283 | }; | 295 | }; |
284 | 296 | ||
@@ -307,6 +319,7 @@ struct load_slide_event_data { | |||
307 | enum pf_scroll_line_type { | 319 | enum pf_scroll_line_type { |
308 | PF_SCROLL_TRACK = 0, | 320 | PF_SCROLL_TRACK = 0, |
309 | PF_SCROLL_ALBUM, | 321 | PF_SCROLL_ALBUM, |
322 | PF_SCROLL_ARTIST, | ||
310 | PF_MAX_SCROLL_LINES | 323 | PF_MAX_SCROLL_LINES |
311 | }; | 324 | }; |
312 | 325 | ||
@@ -332,13 +345,17 @@ struct pfraw_header { | |||
332 | enum show_album_name_values { | 345 | enum show_album_name_values { |
333 | ALBUM_NAME_HIDE = 0, | 346 | ALBUM_NAME_HIDE = 0, |
334 | ALBUM_NAME_BOTTOM, | 347 | ALBUM_NAME_BOTTOM, |
335 | ALBUM_NAME_TOP | 348 | ALBUM_NAME_TOP, |
349 | ALBUM_AND_ARTIST_TOP, | ||
350 | ALBUM_AND_ARTIST_BOTTOM | ||
336 | }; | 351 | }; |
337 | static char* show_album_name_conf[] = | 352 | static char* show_album_name_conf[] = |
338 | { | 353 | { |
339 | "hide", | 354 | "hide", |
340 | "bottom", | 355 | "bottom", |
341 | "top" | 356 | "top", |
357 | "both top", | ||
358 | "both bottom", | ||
342 | }; | 359 | }; |
343 | 360 | ||
344 | #define MAX_SPACING 40 | 361 | #define MAX_SPACING 40 |
@@ -370,7 +387,7 @@ static struct configdata config[] = | |||
370 | { TYPE_BOOL, 0, 1, { .bool_p = &show_fps }, "show fps", NULL }, | 387 | { TYPE_BOOL, 0, 1, { .bool_p = &show_fps }, "show fps", NULL }, |
371 | { TYPE_BOOL, 0, 1, { .bool_p = &resize }, "resize", NULL }, | 388 | { TYPE_BOOL, 0, 1, { .bool_p = &resize }, "resize", NULL }, |
372 | { TYPE_INT, 0, 100, { .int_p = &cache_version }, "cache version", NULL }, | 389 | { TYPE_INT, 0, 100, { .int_p = &cache_version }, "cache version", NULL }, |
373 | { TYPE_ENUM, 0, 3, { .int_p = &show_album_name }, "show album name", | 390 | { TYPE_ENUM, 0, 5, { .int_p = &show_album_name }, "show album name", |
374 | show_album_name_conf }, | 391 | show_album_name_conf }, |
375 | { TYPE_INT, 0, 2, { .int_p = &auto_wps }, "auto wps", NULL }, | 392 | { TYPE_INT, 0, 2, { .int_p = &auto_wps }, "auto wps", NULL }, |
376 | { TYPE_INT, 0, 999999, { .int_p = &last_album }, "last album", NULL }, | 393 | { TYPE_INT, 0, 999999, { .int_p = &last_album }, "last album", NULL }, |
@@ -417,9 +434,14 @@ static struct tagcache_search tcs; | |||
417 | static struct buflib_context buf_ctx; | 434 | static struct buflib_context buf_ctx; |
418 | 435 | ||
419 | static struct album_data *album; | 436 | static struct album_data *album; |
437 | static struct artist_data *artist; | ||
438 | |||
420 | static char *album_names; | 439 | static char *album_names; |
421 | static int album_count; | 440 | static int album_count; |
422 | 441 | ||
442 | static char *artist_names; | ||
443 | static int artist_count; | ||
444 | |||
423 | static struct track_data *tracks; | 445 | static struct track_data *tracks; |
424 | static char *track_names; | 446 | static char *track_names; |
425 | static size_t borrowed = 0; | 447 | static size_t borrowed = 0; |
@@ -833,45 +855,137 @@ static void init_reflect_table(void) | |||
833 | } | 855 | } |
834 | 856 | ||
835 | /** | 857 | /** |
836 | Create an index of all albums from the database. | 858 | Create an index of all artists and albums from the database. |
837 | Also store the album names so we can access them later. | 859 | Also store the artists and album names so we can access them later. |
838 | */ | 860 | */ |
839 | static int create_album_index(void) | 861 | static int create_album_index(void) |
840 | { | 862 | { |
841 | album = ((struct album_data *)(buf_size + (char *) buf)) - 1; | 863 | artist = ((struct artist_data *)(buf_size + (char *) buf)) - 1; |
842 | rb->memset(&tcs, 0, sizeof(struct tagcache_search) ); | 864 | rb->memset(&tcs, 0, sizeof(struct tagcache_search) ); |
843 | album_count = 0; | 865 | artist_count = 0; |
844 | rb->tagcache_search(&tcs, tag_album); | 866 | rb->tagcache_search(&tcs, tag_albumartist); |
845 | unsigned int l, name_idx = 0; | 867 | unsigned int l, name_idx = 0; |
846 | album_names = buf; | 868 | artist_names = buf; |
847 | while (rb->tagcache_get_next(&tcs)) | 869 | while (rb->tagcache_get_next(&tcs)) |
848 | { | 870 | { |
849 | buf_size -= sizeof(struct album_data); | 871 | buf_size -= sizeof(struct artist_data); |
850 | l = tcs.result_len; | 872 | l = tcs.result_len; |
851 | album[-album_count].name_idx = name_idx; | 873 | artist[-artist_count].name_idx = name_idx; |
852 | 874 | artist[-artist_count].seek = tcs.result_seek; | |
853 | if ( l > buf_size ) | 875 | if ( l > buf_size ) |
854 | /* not enough memory */ | 876 | /* not enough memory */ |
855 | return ERROR_BUFFER_FULL; | 877 | return ERROR_BUFFER_FULL; |
856 | |||
857 | rb->strcpy(buf, tcs.result); | 878 | rb->strcpy(buf, tcs.result); |
858 | buf_size -= l; | 879 | buf_size -= l; |
859 | buf = l + (char *)buf; | 880 | buf = l + (char *)buf; |
860 | album[-album_count].seek = tcs.result_seek; | ||
861 | name_idx += l; | 881 | name_idx += l; |
862 | album_count++; | 882 | artist_count++; |
863 | } | 883 | } |
864 | rb->tagcache_search_finish(&tcs); | 884 | rb->tagcache_search_finish(&tcs); |
865 | ALIGN_BUFFER(buf, buf_size, 4); | 885 | ALIGN_BUFFER(buf, buf_size, 4); |
866 | int i; | 886 | int i; |
887 | struct artist_data* tmp_artist = (struct artist_data*)buf; | ||
888 | for (i = artist_count - 1; i >= 0; i--) | ||
889 | tmp_artist[i] = artist[-i]; | ||
890 | artist = tmp_artist; | ||
891 | buf = artist + artist_count; | ||
892 | |||
893 | long artist_seek = 0; | ||
894 | int j = 0; | ||
895 | album_count = 0; | ||
896 | name_idx = 0; | ||
897 | album = ((struct album_data *)(buf_size + (char *) buf)) - 1; | ||
898 | album_names = buf; | ||
899 | for (j = 0; j < artist_count; j++){ | ||
900 | artist_seek = artist[j].seek; | ||
901 | rb->memset(&tcs, 0, sizeof(struct tagcache_search) ); | ||
902 | rb->tagcache_search(&tcs, tag_album); | ||
903 | /* Prevent duplicate entries in the search list. */ | ||
904 | rb->tagcache_search_set_uniqbuf(&tcs, uniqbuf, UNIQBUF_SIZE); | ||
905 | rb->tagcache_search_add_filter(&tcs, tag_albumartist, artist_seek); | ||
906 | while (rb->tagcache_get_next(&tcs)) | ||
907 | { | ||
908 | buf_size -= sizeof(struct album_data); | ||
909 | l = tcs.result_len; | ||
910 | album[-album_count].name_idx = name_idx; | ||
911 | album[-album_count].seek = tcs.result_seek; | ||
912 | album[-album_count].artist_idx = j; | ||
913 | if ( l > buf_size ) | ||
914 | /* not enough memory */ | ||
915 | return ERROR_BUFFER_FULL; | ||
916 | |||
917 | rb->strcpy(buf, tcs.result); | ||
918 | buf_size -= l; | ||
919 | buf = l + (char *)buf; | ||
920 | name_idx += l; | ||
921 | album_count++; | ||
922 | } | ||
923 | rb->tagcache_search_finish(&tcs); | ||
924 | } | ||
925 | ALIGN_BUFFER(buf, buf_size, 4); | ||
867 | struct album_data* tmp_album = (struct album_data*)buf; | 926 | struct album_data* tmp_album = (struct album_data*)buf; |
868 | for (i = album_count - 1; i >= 0; i--) | 927 | for (i = album_count - 1; i >= 0; i--) |
869 | tmp_album[i] = album[-i]; | 928 | tmp_album[i] = album[-i]; |
870 | album = tmp_album; | 929 | album = tmp_album; |
871 | buf = album + album_count; | 930 | buf = album + album_count; |
931 | |||
872 | return (album_count > 0) ? 0 : ERROR_NO_ALBUMS; | 932 | return (album_count > 0) ? 0 : ERROR_NO_ALBUMS; |
873 | } | 933 | } |
874 | 934 | ||
935 | |||
936 | /*Saves the artists+albums index into a binary file to be recovered the | ||
937 | next time PictureFlow is launched*/ | ||
938 | |||
939 | static int save_album_index(void){ | ||
940 | int fd; | ||
941 | fd = rb->creat(PLUGIN_DIR "/demos/album_ndx.tmp",0666); | ||
942 | if(fd >= 0) | ||
943 | { | ||
944 | int unsigned_size = sizeof(unsigned int); | ||
945 | int int_size = sizeof(int); | ||
946 | rb->write(fd, artist_names, ((char *)buf - (char *)artist_names)); | ||
947 | unsigned int artist_pos = (char *)artist - (char *)artist_names; | ||
948 | rb->write(fd, &artist_pos, unsigned_size); | ||
949 | unsigned int album_names_pos = (char *)album_names - (char *)artist_names; | ||
950 | rb->write(fd, &album_names_pos, unsigned_size); | ||
951 | unsigned int album_pos = (char *)album - (char *)artist_names; | ||
952 | rb->write(fd, &album_pos, unsigned_size); | ||
953 | rb->write(fd, &artist_count, int_size); | ||
954 | rb->write(fd, &album_count, int_size); | ||
955 | rb->close(fd); | ||
956 | return 0; | ||
957 | } | ||
958 | return -1; | ||
959 | } | ||
960 | |||
961 | /*Loads the artists+albums index information stored in the hard drive*/ | ||
962 | |||
963 | static int load_album_index(void){ | ||
964 | int fr = rb->open(PLUGIN_DIR "/demos/album_ndx.tmp", O_RDONLY); | ||
965 | if (fr >= 0){ | ||
966 | int unsigned_size = sizeof(unsigned int); | ||
967 | int int_size = sizeof(int); | ||
968 | unsigned long filesize = rb->filesize(fr); | ||
969 | unsigned int pos = 0; | ||
970 | unsigned int extra_data_size = (sizeof(unsigned int)*3) + (sizeof(int)*2); | ||
971 | rb->read(fr,buf ,filesize-extra_data_size); | ||
972 | artist_names = buf; | ||
973 | buf = (char *)buf + (filesize-extra_data_size); | ||
974 | buf_size = buf_size-(filesize-extra_data_size); | ||
975 | rb->read(fr,&pos ,unsigned_size); | ||
976 | artist = (void *)artist_names + pos; | ||
977 | rb->read(fr,&pos ,unsigned_size); | ||
978 | album_names = (void *)artist_names + pos; | ||
979 | rb->read(fr,&pos ,unsigned_size); | ||
980 | album = (void *)artist_names + pos; | ||
981 | rb->read(fr,&artist_count ,int_size); | ||
982 | rb->read(fr,&album_count ,int_size); | ||
983 | rb->close(fr); | ||
984 | return 0; | ||
985 | } | ||
986 | return -1; | ||
987 | } | ||
988 | |||
875 | /** | 989 | /** |
876 | Return a pointer to the album name of the given slide_index | 990 | Return a pointer to the album name of the given slide_index |
877 | */ | 991 | */ |
@@ -881,6 +995,21 @@ static char* get_album_name(const int slide_index) | |||
881 | } | 995 | } |
882 | 996 | ||
883 | /** | 997 | /** |
998 | Return a pointer to the album artist of the given slide_index | ||
999 | */ | ||
1000 | static char* get_album_artist(const int slide_index) | ||
1001 | { | ||
1002 | if (slide_index < album_count && slide_index >= 0){ | ||
1003 | int artist_pos = album[slide_index].artist_idx; | ||
1004 | if (artist_pos < artist_count && artist_pos >= 0){ | ||
1005 | return artist_names + artist[artist_pos].name_idx; | ||
1006 | } | ||
1007 | } | ||
1008 | return NULL; | ||
1009 | } | ||
1010 | |||
1011 | |||
1012 | /** | ||
884 | Return a pointer to the track name of the active album | 1013 | Return a pointer to the track name of the active album |
885 | create_track_index has to be called first. | 1014 | create_track_index has to be called first. |
886 | */ | 1015 | */ |
@@ -902,11 +1031,13 @@ static char* get_track_filename(const int track_index) | |||
902 | static int get_wps_current_index(void) | 1031 | static int get_wps_current_index(void) |
903 | { | 1032 | { |
904 | struct mp3entry *id3 = rb->audio_current_track(); | 1033 | struct mp3entry *id3 = rb->audio_current_track(); |
1034 | |||
905 | if(id3 && id3->album) { | 1035 | if(id3 && id3->album) { |
906 | int i; | 1036 | int i; |
907 | for( i=0; i < album_count; i++ ) | 1037 | for( i=0; i < album_count; i++ ) |
908 | { | 1038 | { |
909 | if(!rb->strcmp(album_names + album[i].name_idx, id3->album)) | 1039 | if(!rb->strcmp(album_names + album[i].name_idx, id3->album) && |
1040 | !rb->strcmp(artist_names + artist[album[i].artist_idx].name_idx, id3->albumartist)) | ||
910 | return i; | 1041 | return i; |
911 | } | 1042 | } |
912 | } | 1043 | } |
@@ -936,6 +1067,7 @@ static void create_track_index(const int slide_index) | |||
936 | goto fail; | 1067 | goto fail; |
937 | 1068 | ||
938 | rb->tagcache_search_add_filter(&tcs, tag_album, album[slide_index].seek); | 1069 | rb->tagcache_search_add_filter(&tcs, tag_album, album[slide_index].seek); |
1070 | rb->tagcache_search_add_filter(&tcs, tag_albumartist, artist[album[slide_index].artist_idx].seek); | ||
939 | track_count=0; | 1071 | track_count=0; |
940 | int string_index = 0, track_num; | 1072 | int string_index = 0, track_num; |
941 | int disc_num; | 1073 | int disc_num; |
@@ -1051,6 +1183,7 @@ static bool get_albumart_for_index_from_db(const int slide_index, char *buf, | |||
1051 | bool result; | 1183 | bool result; |
1052 | /* find the first track of the album */ | 1184 | /* find the first track of the album */ |
1053 | rb->tagcache_search_add_filter(&tcs, tag_album, album[slide_index].seek); | 1185 | rb->tagcache_search_add_filter(&tcs, tag_album, album[slide_index].seek); |
1186 | rb->tagcache_search_add_filter(&tcs, tag_albumartist, artist[album[slide_index].artist_idx].seek); | ||
1054 | 1187 | ||
1055 | if ( rb->tagcache_get_next(&tcs) ) { | 1188 | if ( rb->tagcache_get_next(&tcs) ) { |
1056 | struct mp3entry id3; | 1189 | struct mp3entry id3; |
@@ -1138,6 +1271,13 @@ static void draw_progressbar(int step) | |||
1138 | const int w = LCD_WIDTH - 20; | 1271 | const int w = LCD_WIDTH - 20; |
1139 | const int x = 10; | 1272 | const int x = 10; |
1140 | 1273 | ||
1274 | #if LCD_DEPTH > 1 | ||
1275 | rb->lcd_set_background(N_BRIGHT(0)); | ||
1276 | rb->lcd_set_foreground(N_BRIGHT(255)); | ||
1277 | #else | ||
1278 | rb->lcd_set_drawmode(PICTUREFLOW_DRMODE); | ||
1279 | #endif | ||
1280 | rb->lcd_clear_display(); | ||
1141 | rb->lcd_getstringsize("Preparing album artwork", &txt_w, &txt_h); | 1281 | rb->lcd_getstringsize("Preparing album artwork", &txt_w, &txt_h); |
1142 | 1282 | ||
1143 | int y = (LCD_HEIGHT - txt_h)/2; | 1283 | int y = (LCD_HEIGHT - txt_h)/2; |
@@ -1221,9 +1361,8 @@ static bool create_albumart_cache(void) | |||
1221 | for (i=0; i < album_count; i++) | 1361 | for (i=0; i < album_count; i++) |
1222 | { | 1362 | { |
1223 | draw_progressbar(i); | 1363 | draw_progressbar(i); |
1224 | 1364 | rb->snprintf(pfraw_file, sizeof(pfraw_file), CACHE_PREFIX "/%x%x.pfraw", | |
1225 | rb->snprintf(pfraw_file, sizeof(pfraw_file), CACHE_PREFIX "/%x.pfraw", | 1365 | mfnv(get_album_name(i)),mfnv(get_album_artist(i))); |
1226 | mfnv(get_album_name(i))); | ||
1227 | /* delete existing cache, so it's a true rebuild */ | 1366 | /* delete existing cache, so it's a true rebuild */ |
1228 | if(rb->file_exists(pfraw_file)) { | 1367 | if(rb->file_exists(pfraw_file)) { |
1229 | if(update) { | 1368 | if(update) { |
@@ -1572,8 +1711,10 @@ static inline bool load_and_prepare_surface(const int slide_index, | |||
1572 | const int prio) | 1711 | const int prio) |
1573 | { | 1712 | { |
1574 | char pfraw_file[MAX_PATH]; | 1713 | char pfraw_file[MAX_PATH]; |
1575 | rb->snprintf(pfraw_file, sizeof(pfraw_file), CACHE_PREFIX "/%x.pfraw", | 1714 | |
1576 | mfnv(get_album_name(slide_index))); | 1715 | |
1716 | rb->snprintf(pfraw_file, sizeof(pfraw_file), CACHE_PREFIX "/%x%x.pfraw", | ||
1717 | mfnv(get_album_name(slide_index)),mfnv(get_album_artist(slide_index))); | ||
1577 | 1718 | ||
1578 | int hid = read_pfraw(pfraw_file, prio); | 1719 | int hid = read_pfraw(pfraw_file, prio); |
1579 | if (!hid) | 1720 | if (!hid) |
@@ -2243,13 +2384,16 @@ static int settings_menu(void) | |||
2243 | ID2P(LANG_SHOW_ALBUM_TITLE), | 2384 | ID2P(LANG_SHOW_ALBUM_TITLE), |
2244 | ID2P(LANG_RESIZE_COVERS), | 2385 | ID2P(LANG_RESIZE_COVERS), |
2245 | ID2P(LANG_REBUILD_CACHE), | 2386 | ID2P(LANG_REBUILD_CACHE), |
2387 | ID2P(LANG_UPDATE_CACHE), | ||
2246 | ID2P(LANG_WPS_INTEGRATION), | 2388 | ID2P(LANG_WPS_INTEGRATION), |
2247 | ID2P(LANG_BACKLIGHT)); | 2389 | ID2P(LANG_BACKLIGHT)); |
2248 | 2390 | ||
2249 | static const struct opt_items album_name_options[] = { | 2391 | static const struct opt_items album_name_options[] = { |
2250 | { STR(LANG_HIDE_ALBUM_TITLE) }, | 2392 | { STR(LANG_HIDE_ALBUM_TITLE_NEW) }, |
2251 | { STR(LANG_SHOW_AT_THE_BOTTOM) }, | 2393 | { STR(LANG_SHOW_AT_THE_BOTTOM_NEW) }, |
2252 | { STR(LANG_SHOW_AT_THE_TOP) } | 2394 | { STR(LANG_SHOW_AT_THE_TOP_NEW) }, |
2395 | { STR(LANG_SHOW_ALL_AT_THE_TOP) }, | ||
2396 | { STR(LANG_SHOW_ALL_AT_THE_BOTTOM) }, | ||
2253 | }; | 2397 | }; |
2254 | static const struct opt_items wps_options[] = { | 2398 | static const struct opt_items wps_options[] = { |
2255 | { STR(LANG_OFF) }, | 2399 | { STR(LANG_OFF) }, |
@@ -2300,7 +2444,7 @@ static int settings_menu(void) | |||
2300 | break; | 2444 | break; |
2301 | case 5: | 2445 | case 5: |
2302 | rb->set_option(rb->str(LANG_SHOW_ALBUM_TITLE), &show_album_name, | 2446 | rb->set_option(rb->str(LANG_SHOW_ALBUM_TITLE), &show_album_name, |
2303 | INT, album_name_options, 3, NULL); | 2447 | INT, album_name_options, 5, NULL); |
2304 | reset_track_list(); | 2448 | reset_track_list(); |
2305 | recalc_offsets(); | 2449 | recalc_offsets(); |
2306 | reset_slides(); | 2450 | reset_slides(); |
@@ -2319,9 +2463,16 @@ static int settings_menu(void) | |||
2319 | rb->splash(HZ, ID2P(LANG_CACHE_REBUILT_NEXT_RESTART)); | 2463 | rb->splash(HZ, ID2P(LANG_CACHE_REBUILT_NEXT_RESTART)); |
2320 | break; | 2464 | break; |
2321 | case 8: | 2465 | case 8: |
2322 | rb->set_option(rb->str(LANG_WPS_INTEGRATION), &auto_wps, INT, wps_options, 3, NULL); | 2466 | cache_version = CACHE_UPDATE; |
2467 | rb->remove(EMPTY_SLIDE); | ||
2468 | configfile_save(CONFIG_FILE, config, | ||
2469 | CONFIG_NUM_ITEMS, CONFIG_VERSION); | ||
2470 | rb->splash(HZ, ID2P(LANG_CACHE_REBUILT_NEXT_RESTART)); | ||
2323 | break; | 2471 | break; |
2324 | case 9: | 2472 | case 9: |
2473 | rb->set_option(rb->str(LANG_WPS_INTEGRATION), &auto_wps, INT, wps_options, 3, NULL); | ||
2474 | break; | ||
2475 | case 10: | ||
2325 | rb->set_option(rb->str(LANG_BACKLIGHT), &backlight_mode, INT, backlight_options, 2, NULL); | 2476 | rb->set_option(rb->str(LANG_BACKLIGHT), &backlight_mode, INT, backlight_options, 2, NULL); |
2326 | break; | 2477 | break; |
2327 | 2478 | ||
@@ -2473,11 +2624,20 @@ static void track_list_yh(int char_height) | |||
2473 | break; | 2624 | break; |
2474 | case ALBUM_NAME_BOTTOM: | 2625 | case ALBUM_NAME_BOTTOM: |
2475 | track_list_y = (show_fps ? char_height : 0); | 2626 | track_list_y = (show_fps ? char_height : 0); |
2476 | track_list_h = LCD_HEIGHT - track_list_y - char_height * 2; | 2627 | track_list_h = LCD_HEIGHT - track_list_y - (char_height * 3); |
2628 | break; | ||
2629 | case ALBUM_AND_ARTIST_TOP: | ||
2630 | track_list_y = char_height * 3; | ||
2631 | track_list_h = LCD_HEIGHT - track_list_y - | ||
2632 | (show_fps ? char_height : 0); | ||
2633 | break; | ||
2634 | case ALBUM_AND_ARTIST_BOTTOM: | ||
2635 | track_list_y = (show_fps ? char_height : 0); | ||
2636 | track_list_h = LCD_HEIGHT - track_list_y - (char_height * 3); | ||
2477 | break; | 2637 | break; |
2478 | case ALBUM_NAME_TOP: | 2638 | case ALBUM_NAME_TOP: |
2479 | default: | 2639 | default: |
2480 | track_list_y = char_height * 2; | 2640 | track_list_y = char_height * 3; |
2481 | track_list_h = LCD_HEIGHT - track_list_y - | 2641 | track_list_h = LCD_HEIGHT - track_list_y - |
2482 | (show_fps ? char_height : 0); | 2642 | (show_fps ? char_height : 0); |
2483 | break; | 2643 | break; |
@@ -2620,9 +2780,10 @@ static void draw_album_text(void) | |||
2620 | 2780 | ||
2621 | int albumtxt_index; | 2781 | int albumtxt_index; |
2622 | int char_height; | 2782 | int char_height; |
2623 | int albumtxt_x, albumtxt_y; | 2783 | int albumtxt_x, albumtxt_y, artisttxt_x; |
2624 | 2784 | ||
2625 | char *albumtxt; | 2785 | char *albumtxt; |
2786 | char *artisttxt; | ||
2626 | int c; | 2787 | int c; |
2627 | /* Draw album text */ | 2788 | /* Draw album text */ |
2628 | if ( pf_state == pf_scrolling ) { | 2789 | if ( pf_state == pf_scrolling ) { |
@@ -2650,13 +2811,33 @@ static void draw_album_text(void) | |||
2650 | } | 2811 | } |
2651 | 2812 | ||
2652 | char_height = rb->screens[SCREEN_MAIN]->getcharheight(); | 2813 | char_height = rb->screens[SCREEN_MAIN]->getcharheight(); |
2653 | if (show_album_name == ALBUM_NAME_TOP) | 2814 | switch(show_album_name){ |
2654 | albumtxt_y = char_height / 2; | 2815 | case ALBUM_AND_ARTIST_TOP: |
2655 | else | 2816 | albumtxt_y = 0; |
2656 | albumtxt_y = LCD_HEIGHT - char_height - char_height/2; | 2817 | break; |
2818 | case ALBUM_NAME_BOTTOM: | ||
2819 | albumtxt_y = (LCD_HEIGHT - char_height - char_height/2 - 10); | ||
2820 | break; | ||
2821 | case ALBUM_AND_ARTIST_BOTTOM: | ||
2822 | albumtxt_y = (LCD_HEIGHT - char_height - char_height/2 - 20); | ||
2823 | break; | ||
2824 | case ALBUM_NAME_TOP: | ||
2825 | default: | ||
2826 | albumtxt_y = char_height / 2; | ||
2827 | break; | ||
2828 | } | ||
2657 | 2829 | ||
2658 | albumtxt_x = get_scroll_line_offset(PF_SCROLL_ALBUM); | 2830 | albumtxt_x = get_scroll_line_offset(PF_SCROLL_ALBUM); |
2659 | mylcd_putsxy(albumtxt_x, albumtxt_y, albumtxt); | 2831 | mylcd_putsxy(albumtxt_x, albumtxt_y, albumtxt); |
2832 | set_scroll_line(artisttxt, PF_SCROLL_ARTIST); | ||
2833 | if ((show_album_name == ALBUM_AND_ARTIST_TOP) | ||
2834 | || (show_album_name == ALBUM_AND_ARTIST_BOTTOM)){ | ||
2835 | |||
2836 | artisttxt = get_album_artist(albumtxt_index); | ||
2837 | set_scroll_line(artisttxt, PF_SCROLL_ARTIST); | ||
2838 | artisttxt_x = get_scroll_line_offset(PF_SCROLL_ARTIST); | ||
2839 | mylcd_putsxy(artisttxt_x, albumtxt_y+20, artisttxt); | ||
2840 | } | ||
2660 | } | 2841 | } |
2661 | 2842 | ||
2662 | /** | 2843 | /** |
@@ -2699,7 +2880,19 @@ static int pictureflow_main(void) | |||
2699 | init_reflect_table(); | 2880 | init_reflect_table(); |
2700 | 2881 | ||
2701 | ALIGN_BUFFER(buf, buf_size, 4); | 2882 | ALIGN_BUFFER(buf, buf_size, 4); |
2702 | ret = create_album_index(); | 2883 | |
2884 | /*Scan will trigger when no file is found or the option was activated*/ | ||
2885 | if ((cache_version != CACHE_VERSION)||(load_album_index() < 0)){ | ||
2886 | rb->splash(HZ/2,"Creating album index, please wait"); | ||
2887 | ret = create_album_index(); | ||
2888 | if (ret == 0){ | ||
2889 | save_album_index(); | ||
2890 | } | ||
2891 | } | ||
2892 | else{ | ||
2893 | ret = 0; | ||
2894 | } | ||
2895 | |||
2703 | if (ret == ERROR_BUFFER_FULL) { | 2896 | if (ret == ERROR_BUFFER_FULL) { |
2704 | error_wait("Not enough memory for album names"); | 2897 | error_wait("Not enough memory for album names"); |
2705 | return PLUGIN_ERROR; | 2898 | return PLUGIN_ERROR; |