diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/pictureflow/pictureflow.c | 282 |
1 files changed, 144 insertions, 138 deletions
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c index 7627ff4a53..eae7a061fd 100644 --- a/apps/plugins/pictureflow/pictureflow.c +++ b/apps/plugins/pictureflow/pictureflow.c | |||
@@ -122,7 +122,7 @@ const struct button_mapping pf_context_buttons[] = | |||
122 | {PF_QUIT, BUTTON_POWER, BUTTON_NONE}, | 122 | {PF_QUIT, BUTTON_POWER, BUTTON_NONE}, |
123 | #elif CONFIG_KEYPAD == SANSA_FUZE_PAD | 123 | #elif CONFIG_KEYPAD == SANSA_FUZE_PAD |
124 | {PF_QUIT, BUTTON_HOME|BUTTON_REPEAT, BUTTON_NONE}, | 124 | {PF_QUIT, BUTTON_HOME|BUTTON_REPEAT, BUTTON_NONE}, |
125 | {PF_TRACKLIST, BUTTON_RIGHT, BUTTON_NONE}, | 125 | {PF_TRACKLIST, BUTTON_RIGHT, BUTTON_NONE}, |
126 | /* These all use short press of BUTTON_POWER for menu, map long POWER to quit | 126 | /* These all use short press of BUTTON_POWER for menu, map long POWER to quit |
127 | */ | 127 | */ |
128 | #elif CONFIG_KEYPAD == SANSA_C200_PAD || CONFIG_KEYPAD == SANSA_M200_PAD || \ | 128 | #elif CONFIG_KEYPAD == SANSA_C200_PAD || CONFIG_KEYPAD == SANSA_M200_PAD || \ |
@@ -237,6 +237,10 @@ typedef fb_data pix_t; | |||
237 | #define EMPTY_SLIDE_BMP PLUGIN_DEMOS_DIR "/pictureflow_emptyslide.bmp" | 237 | #define EMPTY_SLIDE_BMP PLUGIN_DEMOS_DIR "/pictureflow_emptyslide.bmp" |
238 | #define SPLASH_BMP PLUGIN_DEMOS_DIR "/pictureflow_splash.bmp" | 238 | #define SPLASH_BMP PLUGIN_DEMOS_DIR "/pictureflow_splash.bmp" |
239 | 239 | ||
240 | /* some magic numbers for cache_version. */ | ||
241 | #define CACHE_REBUILD 0 | ||
242 | #define CACHE_UPDATE 1 | ||
243 | |||
240 | /* Error return values */ | 244 | /* Error return values */ |
241 | #define ERROR_NO_ALBUMS -1 | 245 | #define ERROR_NO_ALBUMS -1 |
242 | #define ERROR_BUFFER_FULL -2 | 246 | #define ERROR_BUFFER_FULL -2 |
@@ -296,8 +300,11 @@ struct pfraw_header { | |||
296 | int32_t height; /* bmap height in pixels */ | 300 | int32_t height; /* bmap height in pixels */ |
297 | }; | 301 | }; |
298 | 302 | ||
299 | enum show_album_name_values { album_name_hide = 0, album_name_bottom, | 303 | enum show_album_name_values { |
300 | album_name_top }; | 304 | ALBUM_NAME_HIDE = 0, |
305 | ALBUM_NAME_BOTTOM, | ||
306 | ALBUM_NAME_TOP | ||
307 | }; | ||
301 | static char* show_album_name_conf[] = | 308 | static char* show_album_name_conf[] = |
302 | { | 309 | { |
303 | "hide", | 310 | "hide", |
@@ -320,7 +327,7 @@ static int backlight_mode = 0; | |||
320 | static bool resize = true; | 327 | static bool resize = true; |
321 | static int cache_version = 0; | 328 | static int cache_version = 0; |
322 | static int show_album_name = (LCD_HEIGHT > 100) | 329 | static int show_album_name = (LCD_HEIGHT > 100) |
323 | ? album_name_top : album_name_bottom; | 330 | ? ALBUM_NAME_TOP : ALBUM_NAME_BOTTOM; |
324 | 331 | ||
325 | static struct configdata config[] = | 332 | static struct configdata config[] = |
326 | { | 333 | { |
@@ -409,7 +416,7 @@ static int start_index_track_list = 0; | |||
409 | static int track_list_visible_entries = 0; | 416 | static int track_list_visible_entries = 0; |
410 | static int track_list_y; | 417 | static int track_list_y; |
411 | static int track_list_h; | 418 | static int track_list_h; |
412 | static int track_scroll_index = 0; | 419 | static int track_scroll_x = 0; |
413 | static int track_scroll_dir = 1; | 420 | static int track_scroll_dir = 1; |
414 | 421 | ||
415 | /* | 422 | /* |
@@ -441,7 +448,6 @@ static int pf_state; | |||
441 | /** code */ | 448 | /** code */ |
442 | static bool free_slide_prio(int prio); | 449 | static bool free_slide_prio(int prio); |
443 | static inline unsigned fade_color(pix_t c, unsigned a); | 450 | static inline unsigned fade_color(pix_t c, unsigned a); |
444 | bool save_pfraw(char* filename, struct bitmap *bm); | ||
445 | bool load_new_slide(void); | 451 | bool load_new_slide(void); |
446 | int load_surface(int); | 452 | int load_surface(int); |
447 | 453 | ||
@@ -734,15 +740,13 @@ int create_album_index(void) | |||
734 | rb->memset(&tcs, 0, sizeof(struct tagcache_search) ); | 740 | rb->memset(&tcs, 0, sizeof(struct tagcache_search) ); |
735 | album_count = 0; | 741 | album_count = 0; |
736 | rb->tagcache_search(&tcs, tag_album); | 742 | rb->tagcache_search(&tcs, tag_album); |
737 | unsigned int l, old_l = 0; | 743 | unsigned int l, name_idx = 0; |
738 | album_names = buf; | 744 | album_names = buf; |
739 | album[0].name_idx = 0; | ||
740 | while (rb->tagcache_get_next(&tcs)) | 745 | while (rb->tagcache_get_next(&tcs)) |
741 | { | 746 | { |
742 | buf_size -= sizeof(struct album_data); | 747 | buf_size -= sizeof(struct album_data); |
743 | l = tcs.result_len; | 748 | l = tcs.result_len; |
744 | if ( album_count > 0 ) | 749 | album[-album_count].name_idx = name_idx; |
745 | album[-album_count].name_idx = album[1-album_count].name_idx + old_l; | ||
746 | 750 | ||
747 | if ( l > buf_size ) | 751 | if ( l > buf_size ) |
748 | /* not enough memory */ | 752 | /* not enough memory */ |
@@ -752,8 +756,8 @@ int create_album_index(void) | |||
752 | buf_size -= l; | 756 | buf_size -= l; |
753 | buf = l + (char *)buf; | 757 | buf = l + (char *)buf; |
754 | album[-album_count].seek = tcs.result_seek; | 758 | album[-album_count].seek = tcs.result_seek; |
755 | old_l = l; | 759 | name_idx += l; |
756 | album_count++; | 760 | album_count++; |
757 | } | 761 | } |
758 | rb->tagcache_search_finish(&tcs); | 762 | rb->tagcache_search_finish(&tcs); |
759 | ALIGN_BUFFER(buf, buf_size, 4); | 763 | ALIGN_BUFFER(buf, buf_size, 4); |
@@ -799,9 +803,11 @@ int get_wps_current_index(void) | |||
799 | if(id3 && id3->album) { | 803 | if(id3 && id3->album) { |
800 | int i; | 804 | int i; |
801 | for( i=0; i < album_count; i++ ) | 805 | for( i=0; i < album_count; i++ ) |
806 | { | ||
802 | if(!rb->strcmp(album_names + album[i].name_idx, id3->album)) | 807 | if(!rb->strcmp(album_names + album[i].name_idx, id3->album)) |
803 | return i; | 808 | return i; |
804 | } | 809 | } |
810 | } | ||
805 | return last_album; | 811 | return last_album; |
806 | } | 812 | } |
807 | 813 | ||
@@ -894,8 +900,8 @@ retry: | |||
894 | 900 | ||
895 | struct track_data *new_tracks = (struct track_data *)(out + (uintptr_t)tracks); | 901 | struct track_data *new_tracks = (struct track_data *)(out + (uintptr_t)tracks); |
896 | unsigned int bytes = track_count * sizeof(struct track_data); | 902 | unsigned int bytes = track_count * sizeof(struct track_data); |
897 | if (track_count) | 903 | if (track_count) |
898 | rb->memmove(new_tracks, tracks, bytes); | 904 | rb->memmove(new_tracks, tracks, bytes); |
899 | tracks = new_tracks; | 905 | tracks = new_tracks; |
900 | } | 906 | } |
901 | goto retry; | 907 | goto retry; |
@@ -980,7 +986,7 @@ void draw_splashscreen(void) | |||
980 | { | 986 | { |
981 | unsigned char * buf_tmp = buf; | 987 | unsigned char * buf_tmp = buf; |
982 | size_t buf_tmp_size = buf_size; | 988 | size_t buf_tmp_size = buf_size; |
983 | struct screen* display = rb->screens[0]; | 989 | struct screen* display = rb->screens[SCREEN_MAIN]; |
984 | #if FB_DATA_SZ > 1 | 990 | #if FB_DATA_SZ > 1 |
985 | ALIGN_BUFFER(buf_tmp, buf_tmp_size, sizeof(fb_data)); | 991 | ALIGN_BUFFER(buf_tmp, buf_tmp_size, sizeof(fb_data)); |
986 | #endif | 992 | #endif |
@@ -994,8 +1000,8 @@ void draw_splashscreen(void) | |||
994 | #endif | 1000 | #endif |
995 | .data = buf_tmp | 1001 | .data = buf_tmp |
996 | }; | 1002 | }; |
997 | int ret = rb->read_bmp_file(SPLASH_BMP, &logo, buf_tmp_size, FORMAT_NATIVE, | 1003 | int ret = rb->read_bmp_file(SPLASH_BMP, &logo, buf_tmp_size, |
998 | NULL); | 1004 | FORMAT_NATIVE, NULL); |
999 | #if LCD_DEPTH > 1 | 1005 | #if LCD_DEPTH > 1 |
1000 | rb->lcd_set_background(N_BRIGHT(0)); | 1006 | rb->lcd_set_background(N_BRIGHT(0)); |
1001 | rb->lcd_set_foreground(N_BRIGHT(255)); | 1007 | rb->lcd_set_foreground(N_BRIGHT(255)); |
@@ -1060,7 +1066,7 @@ unsigned int mfnv(char *str) | |||
1060 | { | 1066 | { |
1061 | const unsigned int p = 16777619; | 1067 | const unsigned int p = 16777619; |
1062 | unsigned int hash = 0x811C9DC5; // 2166136261; | 1068 | unsigned int hash = 0x811C9DC5; // 2166136261; |
1063 | 1069 | ||
1064 | while(*str) | 1070 | while(*str) |
1065 | hash = (hash ^ *str++) * p; | 1071 | hash = (hash ^ *str++) * p; |
1066 | hash += hash << 13; | 1072 | hash += hash << 13; |
@@ -1072,7 +1078,29 @@ unsigned int mfnv(char *str) | |||
1072 | } | 1078 | } |
1073 | 1079 | ||
1074 | /** | 1080 | /** |
1081 | Save the given bitmap as filename in the pfraw format | ||
1082 | */ | ||
1083 | bool save_pfraw(char* filename, struct bitmap *bm) | ||
1084 | { | ||
1085 | struct pfraw_header bmph; | ||
1086 | bmph.width = bm->width; | ||
1087 | bmph.height = bm->height; | ||
1088 | int fh = rb->creat( filename , 0666); | ||
1089 | if( fh < 0 ) return false; | ||
1090 | rb->write( fh, &bmph, sizeof( struct pfraw_header ) ); | ||
1091 | int y; | ||
1092 | for( y = 0; y < bm->height; y++ ) | ||
1093 | { | ||
1094 | pix_t *d = (pix_t*)( bm->data ) + (y*bm->width); | ||
1095 | rb->write( fh, d, sizeof( pix_t ) * bm->width ); | ||
1096 | } | ||
1097 | rb->close( fh ); | ||
1098 | return true; | ||
1099 | } | ||
1100 | |||
1101 | /** | ||
1075 | Precomupte the album art images and store them in CACHE_PREFIX. | 1102 | Precomupte the album art images and store them in CACHE_PREFIX. |
1103 | Use the "?" bitmap if image is not found. | ||
1076 | */ | 1104 | */ |
1077 | bool create_albumart_cache(void) | 1105 | bool create_albumart_cache(void) |
1078 | { | 1106 | { |
@@ -1084,8 +1112,8 @@ bool create_albumart_cache(void) | |||
1084 | char pfraw_file[MAX_PATH]; | 1112 | char pfraw_file[MAX_PATH]; |
1085 | char albumart_file[MAX_PATH]; | 1113 | char albumart_file[MAX_PATH]; |
1086 | unsigned int format = FORMAT_NATIVE; | 1114 | unsigned int format = FORMAT_NATIVE; |
1087 | bool forced = cache_version == 0; | 1115 | bool update = (cache_version == CACHE_UPDATE); |
1088 | cache_version = 0; | 1116 | cache_version = CACHE_REBUILD; |
1089 | configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION); | 1117 | configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION); |
1090 | if (resize) | 1118 | if (resize) |
1091 | format |= FORMAT_RESIZE|FORMAT_KEEP_ASPECT; | 1119 | format |= FORMAT_RESIZE|FORMAT_KEEP_ASPECT; |
@@ -1095,7 +1123,7 @@ bool create_albumart_cache(void) | |||
1095 | mfnv(get_album_name(i))); | 1123 | mfnv(get_album_name(i))); |
1096 | /* delete existing cache, so it's a true rebuild */ | 1124 | /* delete existing cache, so it's a true rebuild */ |
1097 | if(rb->file_exists(pfraw_file)) { | 1125 | if(rb->file_exists(pfraw_file)) { |
1098 | if(!forced) | 1126 | if(update) |
1099 | continue; | 1127 | continue; |
1100 | rb->remove(pfraw_file); | 1128 | rb->remove(pfraw_file); |
1101 | } | 1129 | } |
@@ -1106,11 +1134,13 @@ bool create_albumart_cache(void) | |||
1106 | input_bmp.data = buf; | 1134 | input_bmp.data = buf; |
1107 | input_bmp.width = DISPLAY_WIDTH; | 1135 | input_bmp.width = DISPLAY_WIDTH; |
1108 | input_bmp.height = DISPLAY_HEIGHT; | 1136 | input_bmp.height = DISPLAY_HEIGHT; |
1109 | ret = read_image_file(albumart_file, &input_bmp, buf_size, format, &format_transposed); | 1137 | ret = read_image_file(albumart_file, &input_bmp, buf_size, |
1138 | format, &format_transposed); | ||
1110 | if (ret <= 0) { | 1139 | if (ret <= 0) { |
1111 | rb->splashf(HZ, "Album art is bad: %s", get_album_name(i)); | 1140 | rb->splashf(HZ, "Album art is bad: %s", get_album_name(i)); |
1112 | rb->strcpy(albumart_file, EMPTY_SLIDE_BMP); | 1141 | rb->strcpy(albumart_file, EMPTY_SLIDE_BMP); |
1113 | ret = read_image_file(albumart_file, &input_bmp, buf_size, format, &format_transposed); | 1142 | ret = read_image_file(albumart_file, &input_bmp, buf_size, |
1143 | format, &format_transposed); | ||
1114 | if(ret <= 0) | 1144 | if(ret <= 0) |
1115 | continue; | 1145 | continue; |
1116 | } | 1146 | } |
@@ -1130,6 +1160,32 @@ bool create_albumart_cache(void) | |||
1130 | } | 1160 | } |
1131 | 1161 | ||
1132 | /** | 1162 | /** |
1163 | Create the "?" slide, that is shown while loading | ||
1164 | or when no cover was found. | ||
1165 | */ | ||
1166 | int create_empty_slide(bool force) | ||
1167 | { | ||
1168 | if ( force || ! rb->file_exists( EMPTY_SLIDE ) ) { | ||
1169 | struct bitmap input_bmp; | ||
1170 | int ret; | ||
1171 | input_bmp.width = DISPLAY_WIDTH; | ||
1172 | input_bmp.height = DISPLAY_HEIGHT; | ||
1173 | #if LCD_DEPTH > 1 | ||
1174 | input_bmp.format = FORMAT_NATIVE; | ||
1175 | #endif | ||
1176 | input_bmp.data = (char*)buf; | ||
1177 | ret = scaled_read_bmp_file(EMPTY_SLIDE_BMP, &input_bmp, | ||
1178 | buf_size, | ||
1179 | FORMAT_NATIVE|FORMAT_RESIZE|FORMAT_KEEP_ASPECT, | ||
1180 | &format_transposed); | ||
1181 | if (!save_pfraw(EMPTY_SLIDE, &input_bmp)) | ||
1182 | return false; | ||
1183 | } | ||
1184 | |||
1185 | return true; | ||
1186 | } | ||
1187 | |||
1188 | /** | ||
1133 | Thread used for loading and preparing bitmaps in the background | 1189 | Thread used for loading and preparing bitmaps in the background |
1134 | */ | 1190 | */ |
1135 | void thread(void) | 1191 | void thread(void) |
@@ -1146,7 +1202,7 @@ void thread(void) | |||
1146 | break; | 1202 | break; |
1147 | } | 1203 | } |
1148 | if(ev.id != SYS_TIMEOUT) | 1204 | if(ev.id != SYS_TIMEOUT) |
1149 | while ( load_new_slide() ) { | 1205 | while ( load_new_slide() ) { |
1150 | rb->yield(); | 1206 | rb->yield(); |
1151 | switch (ev.id) { | 1207 | switch (ev.id) { |
1152 | case EV_EXIT: | 1208 | case EV_EXIT: |
@@ -1169,7 +1225,6 @@ void end_pf_thread(void) | |||
1169 | rb->queue_delete(&thread_q); | 1225 | rb->queue_delete(&thread_q); |
1170 | thread_is_running = false; | 1226 | thread_is_running = false; |
1171 | } | 1227 | } |
1172 | |||
1173 | } | 1228 | } |
1174 | 1229 | ||
1175 | 1230 | ||
@@ -1198,27 +1253,6 @@ bool create_pf_thread(void) | |||
1198 | return true; | 1253 | return true; |
1199 | } | 1254 | } |
1200 | 1255 | ||
1201 | /** | ||
1202 | Safe the given bitmap as filename in the pfraw format | ||
1203 | */ | ||
1204 | bool save_pfraw(char* filename, struct bitmap *bm) | ||
1205 | { | ||
1206 | struct pfraw_header bmph; | ||
1207 | bmph.width = bm->width; | ||
1208 | bmph.height = bm->height; | ||
1209 | int fh = rb->creat( filename , 0666); | ||
1210 | if( fh < 0 ) return false; | ||
1211 | rb->write( fh, &bmph, sizeof( struct pfraw_header ) ); | ||
1212 | int y; | ||
1213 | for( y = 0; y < bm->height; y++ ) | ||
1214 | { | ||
1215 | pix_t *d = (pix_t*)( bm->data ) + (y*bm->width); | ||
1216 | rb->write( fh, d, sizeof( pix_t ) * bm->width ); | ||
1217 | } | ||
1218 | rb->close( fh ); | ||
1219 | return true; | ||
1220 | } | ||
1221 | |||
1222 | 1256 | ||
1223 | /* | 1257 | /* |
1224 | * The following functions implement the linked-list-in-array used to manage | 1258 | * The following functions implement the linked-list-in-array used to manage |
@@ -1389,7 +1423,7 @@ int read_pfraw(char* filename, int prio) | |||
1389 | struct pfraw_header bmph; | 1423 | struct pfraw_header bmph; |
1390 | int fh = rb->open(filename, O_RDONLY); | 1424 | int fh = rb->open(filename, O_RDONLY); |
1391 | if( fh < 0 ) { | 1425 | if( fh < 0 ) { |
1392 | cache_version = 1; | 1426 | cache_version = CACHE_UPDATE; |
1393 | return empty_slide_hid; | 1427 | return empty_slide_hid; |
1394 | } | 1428 | } |
1395 | else | 1429 | else |
@@ -1406,7 +1440,7 @@ int read_pfraw(char* filename, int prio) | |||
1406 | return 0; | 1440 | return 0; |
1407 | } | 1441 | } |
1408 | 1442 | ||
1409 | rb->yield(); // allow audio to play when fast scrolling | 1443 | rb->yield(); /* allow audio to play when fast scrolling */ |
1410 | struct dim *bm = buflib_get_data(&buf_ctx, hid); | 1444 | struct dim *bm = buflib_get_data(&buf_ctx, hid); |
1411 | 1445 | ||
1412 | bm->width = bmph.width; | 1446 | bm->width = bmph.width; |
@@ -1431,11 +1465,11 @@ static inline bool load_and_prepare_surface(const int slide_index, | |||
1431 | const int cache_index, | 1465 | const int cache_index, |
1432 | const int prio) | 1466 | const int prio) |
1433 | { | 1467 | { |
1434 | char tmp_path_name[MAX_PATH+1]; | 1468 | char pfraw_file[MAX_PATH]; |
1435 | rb->snprintf(tmp_path_name, sizeof(tmp_path_name), CACHE_PREFIX "/%x.pfraw", | 1469 | rb->snprintf(pfraw_file, sizeof(pfraw_file), CACHE_PREFIX "/%x.pfraw", |
1436 | mfnv(get_album_name(slide_index))); | 1470 | mfnv(get_album_name(slide_index))); |
1437 | 1471 | ||
1438 | int hid = read_pfraw(tmp_path_name, prio); | 1472 | int hid = read_pfraw(pfraw_file, prio); |
1439 | if (!hid) | 1473 | if (!hid) |
1440 | return false; | 1474 | return false; |
1441 | 1475 | ||
@@ -1779,7 +1813,7 @@ void render_slide(struct slide_data *slide, const int alpha) | |||
1779 | dy = (CAM_DIST_R + zo + fmul(xs, sinr)) / CAM_DIST; | 1813 | dy = (CAM_DIST_R + zo + fmul(xs, sinr)) / CAM_DIST; |
1780 | 1814 | ||
1781 | const pix_t *ptr = &src[column * bmp->height]; | 1815 | const pix_t *ptr = &src[column * bmp->height]; |
1782 | 1816 | ||
1783 | #if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE | 1817 | #if defined(LCD_STRIDEFORMAT) && LCD_STRIDEFORMAT == VERTICAL_STRIDE |
1784 | #define PIXELSTEP_Y 1 | 1818 | #define PIXELSTEP_Y 1 |
1785 | #define LCDADDR(x, y) (&buffer[BUFFER_HEIGHT*(x) + (y)]) | 1819 | #define LCDADDR(x, y) (&buffer[BUFFER_HEIGHT*(x) + (y)]) |
@@ -1805,9 +1839,9 @@ void render_slide(struct slide_data *slide, const int alpha) | |||
1805 | pixel -= PIXELSTEP_Y; | 1839 | pixel -= PIXELSTEP_Y; |
1806 | } | 1840 | } |
1807 | } | 1841 | } |
1808 | rb->yield(); // allow audio to play when fast scrolling | 1842 | rb->yield(); /* allow audio to play when fast scrolling */ |
1809 | bmp = surface(slide->slide_index); // resync surface due to yield | 1843 | bmp = surface(slide->slide_index); /* resync surface due to yield */ |
1810 | ptr = &src[column * bmp->height]; | 1844 | ptr = &src[column * bmp->height]; |
1811 | p = (bmp->height-DISPLAY_OFFS) * PFREAL_ONE; | 1845 | p = (bmp->height-DISPLAY_OFFS) * PFREAL_ONE; |
1812 | plim = MIN(sh * PFREAL_ONE, p + (LCD_HEIGHT/2) * dy); | 1846 | plim = MIN(sh * PFREAL_ONE, p + (LCD_HEIGHT/2) * dy); |
1813 | int plim2 = MIN(MIN(sh + REFLECT_HEIGHT, sh * 2) * PFREAL_ONE, | 1847 | int plim2 = MIN(MIN(sh + REFLECT_HEIGHT, sh * 2) * PFREAL_ONE, |
@@ -2087,32 +2121,6 @@ void cleanup(void) | |||
2087 | } | 2121 | } |
2088 | 2122 | ||
2089 | /** | 2123 | /** |
2090 | Create the "?" slide, that is shown while loading | ||
2091 | or when no cover was found. | ||
2092 | */ | ||
2093 | int create_empty_slide(bool force) | ||
2094 | { | ||
2095 | if ( force || ! rb->file_exists( EMPTY_SLIDE ) ) { | ||
2096 | struct bitmap input_bmp; | ||
2097 | int ret; | ||
2098 | input_bmp.width = DISPLAY_WIDTH; | ||
2099 | input_bmp.height = DISPLAY_HEIGHT; | ||
2100 | #if LCD_DEPTH > 1 | ||
2101 | input_bmp.format = FORMAT_NATIVE; | ||
2102 | #endif | ||
2103 | input_bmp.data = (char*)buf; | ||
2104 | ret = scaled_read_bmp_file(EMPTY_SLIDE_BMP, &input_bmp, | ||
2105 | buf_size, | ||
2106 | FORMAT_NATIVE|FORMAT_RESIZE|FORMAT_KEEP_ASPECT, | ||
2107 | &format_transposed); | ||
2108 | if (!save_pfraw(EMPTY_SLIDE, &input_bmp)) | ||
2109 | return false; | ||
2110 | } | ||
2111 | |||
2112 | return true; | ||
2113 | } | ||
2114 | |||
2115 | /** | ||
2116 | Shows the settings menu | 2124 | Shows the settings menu |
2117 | */ | 2125 | */ |
2118 | int settings_menu(void) | 2126 | int settings_menu(void) |
@@ -2131,14 +2139,14 @@ int settings_menu(void) | |||
2131 | { "Show at the top", -1 } | 2139 | { "Show at the top", -1 } |
2132 | }; | 2140 | }; |
2133 | static const struct opt_items wps_options[] = { | 2141 | static const struct opt_items wps_options[] = { |
2134 | { "Off", -1 }, | 2142 | { "Off", -1 }, |
2135 | { "Direct", -1 }, | 2143 | { "Direct", -1 }, |
2136 | { "Via Track list", -1 } | 2144 | { "Via Track list", -1 } |
2137 | }; | 2145 | }; |
2138 | static const struct opt_items backlight_options[] = { | 2146 | static const struct opt_items backlight_options[] = { |
2139 | { "Always On", -1 }, | 2147 | { "Always On", -1 }, |
2140 | { "Normal", -1 }, | 2148 | { "Normal", -1 }, |
2141 | }; | 2149 | }; |
2142 | 2150 | ||
2143 | do { | 2151 | do { |
2144 | selection=rb->do_menu(&settings_menu,&selection, NULL, true); | 2152 | selection=rb->do_menu(&settings_menu,&selection, NULL, true); |
@@ -2191,13 +2199,13 @@ int settings_menu(void) | |||
2191 | break; | 2199 | break; |
2192 | /* fallthrough if changed, since cache needs to be rebuilt */ | 2200 | /* fallthrough if changed, since cache needs to be rebuilt */ |
2193 | case 7: | 2201 | case 7: |
2194 | cache_version = 0; | 2202 | cache_version = CACHE_REBUILD; |
2195 | rb->remove(EMPTY_SLIDE); | 2203 | rb->remove(EMPTY_SLIDE); |
2196 | rb->splash(HZ, "Cache will be rebuilt on next restart"); | 2204 | rb->splash(HZ, "Cache will be rebuilt on next restart"); |
2197 | break; | 2205 | break; |
2198 | case 8: | 2206 | case 8: |
2199 | rb->set_option("WPS Integration", &auto_wps, INT, wps_options, 3, NULL); | 2207 | rb->set_option("WPS Integration", &auto_wps, INT, wps_options, 3, NULL); |
2200 | break; | 2208 | break; |
2201 | case 9: | 2209 | case 9: |
2202 | rb->set_option("Backlight", &backlight_mode, INT, backlight_options, 2, NULL); | 2210 | rb->set_option("Backlight", &backlight_mode, INT, backlight_options, 2, NULL); |
2203 | break; | 2211 | break; |
@@ -2244,12 +2252,12 @@ int main_menu(void) | |||
2244 | case PF_GOTO_WPS: /* WPS */ | 2252 | case PF_GOTO_WPS: /* WPS */ |
2245 | return -2; | 2253 | return -2; |
2246 | #if PF_PLAYBACK_CAPABLE | 2254 | #if PF_PLAYBACK_CAPABLE |
2247 | case PF_MENU_CLEAR_PLAYLIST: | 2255 | case PF_MENU_CLEAR_PLAYLIST: |
2248 | if(rb->playlist_remove_all_tracks(NULL) == 0) { | 2256 | if(rb->playlist_remove_all_tracks(NULL) == 0) { |
2249 | rb->playlist_create(NULL, NULL); | 2257 | rb->playlist_create(NULL, NULL); |
2250 | rb->splash(HZ*2, "Playlist Cleared"); | 2258 | rb->splash(HZ*2, "Playlist Cleared"); |
2251 | } | 2259 | } |
2252 | break; | 2260 | break; |
2253 | case PF_MENU_PLAYBACK_CONTROL: /* Playback Control */ | 2261 | case PF_MENU_PLAYBACK_CONTROL: /* Playback Control */ |
2254 | playback_control(NULL); | 2262 | playback_control(NULL); |
2255 | break; | 2263 | break; |
@@ -2342,15 +2350,16 @@ static void track_list_yh(int char_height) | |||
2342 | { | 2350 | { |
2343 | switch (show_album_name) | 2351 | switch (show_album_name) |
2344 | { | 2352 | { |
2345 | case album_name_hide: | 2353 | case ALBUM_NAME_HIDE: |
2346 | track_list_y = (show_fps ? char_height : 0); | 2354 | track_list_y = (show_fps ? char_height : 0); |
2347 | track_list_h = LCD_HEIGHT - track_list_y; | 2355 | track_list_h = LCD_HEIGHT - track_list_y; |
2348 | break; | 2356 | break; |
2349 | case album_name_bottom: | 2357 | case ALBUM_NAME_BOTTOM: |
2350 | track_list_y = (show_fps ? char_height : 0); | 2358 | track_list_y = (show_fps ? char_height : 0); |
2351 | track_list_h = LCD_HEIGHT - track_list_y - char_height * 2; | 2359 | track_list_h = LCD_HEIGHT - track_list_y - char_height * 2; |
2352 | break; | 2360 | break; |
2353 | default: /* case album_name_top */ | 2361 | case ALBUM_NAME_TOP: |
2362 | default: | ||
2354 | track_list_y = char_height * 2; | 2363 | track_list_y = char_height * 2; |
2355 | track_list_h = LCD_HEIGHT - track_list_y - | 2364 | track_list_h = LCD_HEIGHT - track_list_y - |
2356 | (show_fps ? char_height : 0); | 2365 | (show_fps ? char_height : 0); |
@@ -2363,19 +2372,19 @@ static void track_list_yh(int char_height) | |||
2363 | */ | 2372 | */ |
2364 | void reset_track_list(void) | 2373 | void reset_track_list(void) |
2365 | { | 2374 | { |
2366 | int albumtxt_h = rb->screens[SCREEN_MAIN]->getcharheight(); | 2375 | int char_height = rb->screens[SCREEN_MAIN]->getcharheight(); |
2367 | track_list_yh(albumtxt_h); | 2376 | track_list_yh(char_height); |
2368 | track_list_visible_entries = fmin( track_list_h/albumtxt_h , track_count ); | 2377 | track_list_visible_entries = fmin( track_list_h/char_height , track_count ); |
2369 | start_index_track_list = 0; | 2378 | start_index_track_list = 0; |
2370 | track_scroll_index = 0; | 2379 | track_scroll_x = 0; |
2371 | track_scroll_dir = 1; | 2380 | track_scroll_dir = 1; |
2372 | selected_track = 0; | 2381 | selected_track = 0; |
2373 | 2382 | ||
2374 | /* let the tracklist start more centered | 2383 | /* let the tracklist start more centered |
2375 | * if the screen isn't filled with tracks */ | 2384 | * if the screen isn't filled with tracks */ |
2376 | if (track_count*albumtxt_h < track_list_h) | 2385 | if (track_count*char_height < track_list_h) |
2377 | { | 2386 | { |
2378 | track_list_h = track_count * albumtxt_h; | 2387 | track_list_h = track_count * char_height; |
2379 | track_list_y = LCD_HEIGHT / 2 - (track_list_h / 2); | 2388 | track_list_y = LCD_HEIGHT / 2 - (track_list_h / 2); |
2380 | } | 2389 | } |
2381 | } | 2390 | } |
@@ -2405,11 +2414,11 @@ void show_track_list(void) | |||
2405 | draw_gradient(titletxt_y, titletxt_h); | 2414 | draw_gradient(titletxt_y, titletxt_h); |
2406 | mylcd_set_foreground(G_BRIGHT(255)); | 2415 | mylcd_set_foreground(G_BRIGHT(255)); |
2407 | if (titletxt_w > LCD_WIDTH ) { | 2416 | if (titletxt_w > LCD_WIDTH ) { |
2408 | if ( titletxt_w + track_scroll_index <= LCD_WIDTH ) | 2417 | if ( titletxt_w + track_scroll_x <= LCD_WIDTH ) |
2409 | track_scroll_dir = 1; | 2418 | track_scroll_dir = 1; |
2410 | else if ( track_scroll_index >= 0 ) track_scroll_dir = -1; | 2419 | else if ( track_scroll_x >= 0 ) track_scroll_dir = -1; |
2411 | track_scroll_index += track_scroll_dir*2; | 2420 | track_scroll_x += track_scroll_dir*2; |
2412 | titletxt_x = track_scroll_index; | 2421 | titletxt_x = track_scroll_x; |
2413 | } | 2422 | } |
2414 | mylcd_putsxy(titletxt_x,titletxt_y,get_track_name(track_i)); | 2423 | mylcd_putsxy(titletxt_x,titletxt_y,get_track_name(track_i)); |
2415 | } | 2424 | } |
@@ -2426,7 +2435,7 @@ void select_next_track(void) | |||
2426 | { | 2435 | { |
2427 | if ( selected_track < track_count - 1 ) { | 2436 | if ( selected_track < track_count - 1 ) { |
2428 | selected_track++; | 2437 | selected_track++; |
2429 | track_scroll_index = 0; | 2438 | track_scroll_x = 0; |
2430 | track_scroll_dir = 1; | 2439 | track_scroll_dir = 1; |
2431 | if (selected_track==(track_list_visible_entries+start_index_track_list)) | 2440 | if (selected_track==(track_list_visible_entries+start_index_track_list)) |
2432 | start_index_track_list++; | 2441 | start_index_track_list++; |
@@ -2437,7 +2446,7 @@ void select_prev_track(void) | |||
2437 | { | 2446 | { |
2438 | if (selected_track > 0 ) { | 2447 | if (selected_track > 0 ) { |
2439 | if (selected_track==start_index_track_list) start_index_track_list--; | 2448 | if (selected_track==start_index_track_list) start_index_track_list--; |
2440 | track_scroll_index = 0; | 2449 | track_scroll_x = 0; |
2441 | track_scroll_dir = 1; | 2450 | track_scroll_dir = 1; |
2442 | selected_track--; | 2451 | selected_track--; |
2443 | } | 2452 | } |
@@ -2483,7 +2492,7 @@ play: | |||
2483 | * if shuffle, we can't predict the playing track easily, and for either | 2492 | * if shuffle, we can't predict the playing track easily, and for either |
2484 | * case the track list doesn't get auto scrolled*/ | 2493 | * case the track list doesn't get auto scrolled*/ |
2485 | if(!append) | 2494 | if(!append) |
2486 | rb->playlist_start(position, 0); | 2495 | rb->playlist_start(position, 0); |
2487 | old_playlist = center_slide.slide_index; | 2496 | old_playlist = center_slide.slide_index; |
2488 | old_shuffle = shuffle; | 2497 | old_shuffle = shuffle; |
2489 | } | 2498 | } |
@@ -2494,7 +2503,7 @@ play: | |||
2494 | */ | 2503 | */ |
2495 | void draw_album_text(void) | 2504 | void draw_album_text(void) |
2496 | { | 2505 | { |
2497 | if (0 == show_album_name) | 2506 | if (show_album_name == ALBUM_NAME_HIDE) |
2498 | return; | 2507 | return; |
2499 | 2508 | ||
2500 | int albumtxt_w, albumtxt_h; | 2509 | int albumtxt_w, albumtxt_h; |
@@ -2528,7 +2537,7 @@ void draw_album_text(void) | |||
2528 | prev_center_index = center_index; | 2537 | prev_center_index = center_index; |
2529 | } | 2538 | } |
2530 | 2539 | ||
2531 | if (show_album_name == album_name_top) | 2540 | if (show_album_name == ALBUM_NAME_TOP) |
2532 | albumtxt_y = albumtxt_h / 2; | 2541 | albumtxt_y = albumtxt_h / 2; |
2533 | else | 2542 | else |
2534 | albumtxt_y = LCD_HEIGHT - albumtxt_h - albumtxt_h/2; | 2543 | albumtxt_y = LCD_HEIGHT - albumtxt_h - albumtxt_h/2; |
@@ -2544,8 +2553,6 @@ void draw_album_text(void) | |||
2544 | else { | 2553 | else { |
2545 | mylcd_putsxy((LCD_WIDTH - albumtxt_w) /2, albumtxt_y , albumtxt); | 2554 | mylcd_putsxy((LCD_WIDTH - albumtxt_w) /2, albumtxt_y , albumtxt); |
2546 | } | 2555 | } |
2547 | |||
2548 | |||
2549 | } | 2556 | } |
2550 | 2557 | ||
2551 | /** | 2558 | /** |
@@ -2578,11 +2585,11 @@ int main(void) | |||
2578 | 2585 | ||
2579 | configfile_load(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION); | 2586 | configfile_load(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION); |
2580 | if(auto_wps == 0) | 2587 | if(auto_wps == 0) |
2581 | draw_splashscreen(); | 2588 | draw_splashscreen(); |
2582 | if(backlight_mode == 0) { | 2589 | if(backlight_mode == 0) { |
2583 | /* Turn off backlight timeout */ | 2590 | /* Turn off backlight timeout */ |
2584 | backlight_force_on(); /* backlight control in lib/helper.c */ | 2591 | backlight_force_on(); /* backlight control in lib/helper.c */ |
2585 | } | 2592 | } |
2586 | 2593 | ||
2587 | init_reflect_table(); | 2594 | init_reflect_table(); |
2588 | 2595 | ||
@@ -2713,7 +2720,7 @@ int main(void) | |||
2713 | mylcd_set_foreground(G_PIX(255,0,0)); | 2720 | mylcd_set_foreground(G_PIX(255,0,0)); |
2714 | #endif | 2721 | #endif |
2715 | rb->snprintf(fpstxt, sizeof(fpstxt), "FPS: %d", fps); | 2722 | rb->snprintf(fpstxt, sizeof(fpstxt), "FPS: %d", fps); |
2716 | if (show_album_name == album_name_top) | 2723 | if (show_album_name == ALBUM_NAME_TOP) |
2717 | fpstxt_y = LCD_HEIGHT - | 2724 | fpstxt_y = LCD_HEIGHT - |
2718 | rb->screens[SCREEN_MAIN]->getcharheight(); | 2725 | rb->screens[SCREEN_MAIN]->getcharheight(); |
2719 | else | 2726 | else |
@@ -2783,47 +2790,47 @@ int main(void) | |||
2783 | #if PF_PLAYBACK_CAPABLE | 2790 | #if PF_PLAYBACK_CAPABLE |
2784 | case PF_CONTEXT: | 2791 | case PF_CONTEXT: |
2785 | if ( auto_wps != 0 ) { | 2792 | if ( auto_wps != 0 ) { |
2786 | if( pf_state == pf_idle ) { | 2793 | if( pf_state == pf_idle ) { |
2787 | create_track_index(center_slide.slide_index); | 2794 | create_track_index(center_slide.slide_index); |
2788 | reset_track_list(); | 2795 | reset_track_list(); |
2789 | start_playback(true); | 2796 | start_playback(true); |
2790 | rb->splash(HZ*2, "Added to playlist"); | 2797 | rb->splash(HZ*2, "Added to playlist"); |
2791 | } | 2798 | } |
2792 | else if( pf_state == pf_show_tracks ) { | 2799 | else if( pf_state == pf_show_tracks ) { |
2793 | rb->playlist_insert_track(NULL, get_track_filename(selected_track), | 2800 | rb->playlist_insert_track(NULL, get_track_filename(selected_track), |
2794 | PLAYLIST_INSERT_LAST, false, true); | 2801 | PLAYLIST_INSERT_LAST, false, true); |
2795 | rb->playlist_sync(NULL); | 2802 | rb->playlist_sync(NULL); |
2796 | rb->splash(HZ*2, "Added to playlist"); | 2803 | rb->splash(HZ*2, "Added to playlist"); |
2797 | } | 2804 | } |
2798 | } | 2805 | } |
2799 | break; | 2806 | break; |
2800 | #endif | 2807 | #endif |
2801 | case PF_TRACKLIST: | 2808 | case PF_TRACKLIST: |
2802 | if ( auto_wps == 1 && pf_state == pf_idle ) { | 2809 | if ( auto_wps == 1 && pf_state == pf_idle ) { |
2803 | pf_state = pf_cover_in; | 2810 | pf_state = pf_cover_in; |
2804 | break; | 2811 | break; |
2805 | } | 2812 | } |
2806 | case PF_SELECT: | 2813 | case PF_SELECT: |
2807 | if ( pf_state == pf_idle ) { | 2814 | if ( pf_state == pf_idle ) { |
2808 | #if PF_PLAYBACK_CAPABLE | 2815 | #if PF_PLAYBACK_CAPABLE |
2809 | if(auto_wps == 1) { | 2816 | if(auto_wps == 1) { |
2810 | create_track_index(center_slide.slide_index); | 2817 | create_track_index(center_slide.slide_index); |
2811 | reset_track_list(); | 2818 | reset_track_list(); |
2812 | start_playback(false); | 2819 | start_playback(false); |
2813 | last_album = center_index; | 2820 | last_album = center_index; |
2814 | return PLUGIN_GOTO_WPS; | 2821 | return PLUGIN_GOTO_WPS; |
2815 | } | 2822 | } |
2816 | else | 2823 | else |
2817 | #endif | 2824 | #endif |
2818 | pf_state = pf_cover_in; | 2825 | pf_state = pf_cover_in; |
2819 | } | 2826 | } |
2820 | else if ( pf_state == pf_show_tracks ) { | 2827 | else if ( pf_state == pf_show_tracks ) { |
2821 | #if PF_PLAYBACK_CAPABLE | 2828 | #if PF_PLAYBACK_CAPABLE |
2822 | start_playback(false); | 2829 | start_playback(false); |
2823 | if(auto_wps != 0) { | 2830 | if(auto_wps != 0) { |
2824 | last_album = center_index; | 2831 | last_album = center_index; |
2825 | return PLUGIN_GOTO_WPS; | 2832 | return PLUGIN_GOTO_WPS; |
2826 | } | 2833 | } |
2827 | #endif | 2834 | #endif |
2828 | } | 2835 | } |
2829 | break; | 2836 | break; |
@@ -2873,7 +2880,6 @@ enum plugin_status plugin_start(const void *parameter) | |||
2873 | buf = (void*)(grey_buf_used + (char*)buf); | 2880 | buf = (void*)(grey_buf_used + (char*)buf); |
2874 | #endif | 2881 | #endif |
2875 | 2882 | ||
2876 | atexit(cleanup); | ||
2877 | ret = main(); | 2883 | ret = main(); |
2878 | if ( ret == PLUGIN_OK || ret == PLUGIN_GOTO_WPS) { | 2884 | if ( ret == PLUGIN_OK || ret == PLUGIN_GOTO_WPS) { |
2879 | if (configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, | 2885 | if (configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, |