summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2010-06-09 06:24:22 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2010-06-09 06:24:22 +0000
commit6efc8d5bc16fd2a73731ba17c7f6a03cf2b9b582 (patch)
tree3bb3920c645ee267627009a144d4321f3eba9cf3
parente02ceefdbce2d499981dabae91bce3c465749166 (diff)
downloadrockbox-6efc8d5bc16fd2a73731ba17c7f6a03cf2b9b582.tar.gz
rockbox-6efc8d5bc16fd2a73731ba17c7f6a03cf2b9b582.zip
remainder of FS#11270 - bug fixes and updates for picureflow
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26713 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/pictureflow/pictureflow.c98
1 files changed, 73 insertions, 25 deletions
diff --git a/apps/plugins/pictureflow/pictureflow.c b/apps/plugins/pictureflow/pictureflow.c
index 0ab3ae1132..787dea4cf9 100644
--- a/apps/plugins/pictureflow/pictureflow.c
+++ b/apps/plugins/pictureflow/pictureflow.c
@@ -315,6 +315,7 @@ static int zoom = 100;
315static bool show_fps = false; 315static bool show_fps = false;
316static int auto_wps = 0; 316static int auto_wps = 0;
317static int last_album = 0; 317static int last_album = 0;
318static int backlight_mode = 0;
318static bool resize = true; 319static bool resize = true;
319static int cache_version = 0; 320static int cache_version = 0;
320static int show_album_name = (LCD_HEIGHT > 100) 321static int show_album_name = (LCD_HEIGHT > 100)
@@ -335,7 +336,8 @@ static struct configdata config[] =
335 { TYPE_ENUM, 0, 3, { .int_p = &show_album_name }, "show album name", 336 { TYPE_ENUM, 0, 3, { .int_p = &show_album_name }, "show album name",
336 show_album_name_conf }, 337 show_album_name_conf },
337 { TYPE_INT, 0, 2, { .int_p = &auto_wps }, "auto wps", NULL }, 338 { TYPE_INT, 0, 2, { .int_p = &auto_wps }, "auto wps", NULL },
338 { TYPE_INT, 0, 999999, { .int_p = &last_album }, "last album", NULL } 339 { TYPE_INT, 0, 999999, { .int_p = &last_album }, "last album", NULL },
340 { TYPE_INT, 0, 1, { .int_p = &backlight_mode }, "backlight", NULL }
339}; 341};
340 342
341#define CONFIG_NUM_ITEMS (sizeof(config) / sizeof(struct configdata)) 343#define CONFIG_NUM_ITEMS (sizeof(config) / sizeof(struct configdata))
@@ -888,13 +890,12 @@ retry:
888 buflib_buffer_out(&buf_ctx, &out); 890 buflib_buffer_out(&buf_ctx, &out);
889 avail += out; 891 avail += out;
890 borrowed += out; 892 borrowed += out;
891 if (track_count) 893
892 { 894 struct track_data *new_tracks = (struct track_data *)(out + (uintptr_t)tracks);
893 struct track_data *new_tracks = (struct track_data *)(out + (uintptr_t)tracks); 895 unsigned int bytes = track_count * sizeof(struct track_data);
894 unsigned int bytes = track_count * sizeof(struct track_data); 896 if (track_count)
895 rb->memmove(new_tracks, tracks, bytes); 897 rb->memmove(new_tracks, tracks, bytes);
896 tracks = new_tracks; 898 tracks = new_tracks;
897 }
898 } 899 }
899 goto retry; 900 goto retry;
900 } 901 }
@@ -1051,6 +1052,24 @@ void draw_progressbar(int step)
1051 rb->yield(); 1052 rb->yield();
1052} 1053}
1053 1054
1055/* Calculate modified FNV hash of string
1056 * has good avalanche behaviour and uniform distribution
1057 * see http://home.comcast.net/~bretm/hash/ */
1058unsigned int mfnv(char *str)
1059{
1060 const unsigned int p = 16777619;
1061 unsigned int hash = 0x811C9DC5; // 2166136261;
1062
1063 while(*str)
1064 hash = (hash ^ *str++) * p;
1065 hash += hash << 13;
1066 hash ^= hash >> 7;
1067 hash += hash << 3;
1068 hash ^= hash >> 17;
1069 hash += hash << 5;
1070 return hash;
1071}
1072
1054/** 1073/**
1055 Precomupte the album art images and store them in CACHE_PREFIX. 1074 Precomupte the album art images and store them in CACHE_PREFIX.
1056 */ 1075 */
@@ -1064,29 +1083,35 @@ bool create_albumart_cache(void)
1064 char pfraw_file[MAX_PATH]; 1083 char pfraw_file[MAX_PATH];
1065 char albumart_file[MAX_PATH]; 1084 char albumart_file[MAX_PATH];
1066 unsigned int format = FORMAT_NATIVE; 1085 unsigned int format = FORMAT_NATIVE;
1086 bool forced = cache_version == 0;
1067 cache_version = 0; 1087 cache_version = 0;
1068 configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION); 1088 configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION);
1069 if (resize) 1089 if (resize)
1070 format |= FORMAT_RESIZE|FORMAT_KEEP_ASPECT; 1090 format |= FORMAT_RESIZE|FORMAT_KEEP_ASPECT;
1071 for (i=0; i < album_count; i++) 1091 for (i=0; i < album_count; i++)
1072 { 1092 {
1073 rb->snprintf(pfraw_file, sizeof(pfraw_file), CACHE_PREFIX "/%d.pfraw", 1093 rb->snprintf(pfraw_file, sizeof(pfraw_file), CACHE_PREFIX "/%x.pfraw",
1074 i); 1094 mfnv(get_album_name(i)));
1075 /* delete existing cache, so it's a true rebuild */ 1095 /* delete existing cache, so it's a true rebuild */
1076 if(rb->file_exists(pfraw_file)) 1096 if(rb->file_exists(pfraw_file)) {
1097 if(!forced)
1098 continue;
1077 rb->remove(pfraw_file); 1099 rb->remove(pfraw_file);
1100 }
1078 draw_progressbar(i); 1101 draw_progressbar(i);
1079 if (!get_albumart_for_index_from_db(i, albumart_file, MAX_PATH)) 1102 if (!get_albumart_for_index_from_db(i, albumart_file, MAX_PATH))
1080 continue; 1103 rb->strcpy(albumart_file, EMPTY_SLIDE_BMP);
1081 1104
1082 input_bmp.data = buf; 1105 input_bmp.data = buf;
1083 input_bmp.width = DISPLAY_WIDTH; 1106 input_bmp.width = DISPLAY_WIDTH;
1084 input_bmp.height = DISPLAY_HEIGHT; 1107 input_bmp.height = DISPLAY_HEIGHT;
1085 ret = read_image_file(albumart_file, &input_bmp, 1108 ret = read_image_file(albumart_file, &input_bmp, buf_size, format, &format_transposed);
1086 buf_size, format, &format_transposed);
1087 if (ret <= 0) { 1109 if (ret <= 0) {
1088 rb->splash(HZ, "Could not read bmp"); 1110 rb->splashf(HZ, "Album art is bad: %s", get_album_name(i));
1089 continue; /* skip missing/broken files */ 1111 rb->strcpy(albumart_file, EMPTY_SLIDE_BMP);
1112 ret = read_image_file(albumart_file, &input_bmp, buf_size, format, &format_transposed);
1113 if(ret <= 0)
1114 continue;
1090 } 1115 }
1091 if (!save_pfraw(pfraw_file, &input_bmp)) 1116 if (!save_pfraw(pfraw_file, &input_bmp))
1092 { 1117 {
@@ -1119,7 +1144,8 @@ void thread(void)
1119 /* we just woke up */ 1144 /* we just woke up */
1120 break; 1145 break;
1121 } 1146 }
1122 while ( load_new_slide() ) { 1147 if(ev.id != SYS_TIMEOUT)
1148 while ( load_new_slide() ) {
1123 rb->yield(); 1149 rb->yield();
1124 switch (ev.id) { 1150 switch (ev.id) {
1125 case EV_EXIT: 1151 case EV_EXIT:
@@ -1361,8 +1387,10 @@ int read_pfraw(char* filename, int prio)
1361{ 1387{
1362 struct pfraw_header bmph; 1388 struct pfraw_header bmph;
1363 int fh = rb->open(filename, O_RDONLY); 1389 int fh = rb->open(filename, O_RDONLY);
1364 if( fh < 0 ) 1390 if( fh < 0 ) {
1391 cache_version = 1;
1365 return empty_slide_hid; 1392 return empty_slide_hid;
1393 }
1366 else 1394 else
1367 rb->read(fh, &bmph, sizeof(struct pfraw_header)); 1395 rb->read(fh, &bmph, sizeof(struct pfraw_header));
1368 1396
@@ -1377,6 +1405,7 @@ int read_pfraw(char* filename, int prio)
1377 return 0; 1405 return 0;
1378 } 1406 }
1379 1407
1408 rb->yield(); // allow audio to play when fast scrolling
1380 struct dim *bm = buflib_get_data(&buf_ctx, hid); 1409 struct dim *bm = buflib_get_data(&buf_ctx, hid);
1381 1410
1382 bm->width = bmph.width; 1411 bm->width = bmph.width;
@@ -1402,8 +1431,8 @@ static inline bool load_and_prepare_surface(const int slide_index,
1402 const int prio) 1431 const int prio)
1403{ 1432{
1404 char tmp_path_name[MAX_PATH+1]; 1433 char tmp_path_name[MAX_PATH+1];
1405 rb->snprintf(tmp_path_name, sizeof(tmp_path_name), CACHE_PREFIX "/%d.pfraw", 1434 rb->snprintf(tmp_path_name, sizeof(tmp_path_name), CACHE_PREFIX "/%x.pfraw",
1406 slide_index); 1435 mfnv(get_album_name(slide_index)));
1407 1436
1408 int hid = read_pfraw(tmp_path_name, prio); 1437 int hid = read_pfraw(tmp_path_name, prio);
1409 if (!hid) 1438 if (!hid)
@@ -1775,6 +1804,9 @@ void render_slide(struct slide_data *slide, const int alpha)
1775 pixel -= PIXELSTEP_Y; 1804 pixel -= PIXELSTEP_Y;
1776 } 1805 }
1777 } 1806 }
1807 rb->yield(); // allow audio to play when fast scrolling
1808 bmp = surface(slide->slide_index); // resync surface due to yield
1809 ptr = &src[column * bmp->height];
1778 p = (bmp->height-DISPLAY_OFFS) * PFREAL_ONE; 1810 p = (bmp->height-DISPLAY_OFFS) * PFREAL_ONE;
1779 plim = MIN(sh * PFREAL_ONE, p + (LCD_HEIGHT/2) * dy); 1811 plim = MIN(sh * PFREAL_ONE, p + (LCD_HEIGHT/2) * dy);
1780 int plim2 = MIN(MIN(sh + REFLECT_HEIGHT, sh * 2) * PFREAL_ONE, 1812 int plim2 = MIN(MIN(sh + REFLECT_HEIGHT, sh * 2) * PFREAL_ONE,
@@ -2091,7 +2123,7 @@ int settings_menu(void)
2091 MENUITEM_STRINGLIST(settings_menu, "PictureFlow Settings", NULL, "Show FPS", 2123 MENUITEM_STRINGLIST(settings_menu, "PictureFlow Settings", NULL, "Show FPS",
2092 "Spacing", "Centre margin", "Number of slides", "Zoom", 2124 "Spacing", "Centre margin", "Number of slides", "Zoom",
2093 "Show album title", "Resize Covers", "Rebuild cache", 2125 "Show album title", "Resize Covers", "Rebuild cache",
2094 "WPS Integration"); 2126 "WPS Integration", "Backlight");
2095 2127
2096 static const struct opt_items album_name_options[] = { 2128 static const struct opt_items album_name_options[] = {
2097 { "Hide album title", -1 }, 2129 { "Hide album title", -1 },
@@ -2103,6 +2135,10 @@ int settings_menu(void)
2103 { "Direct", -1 }, 2135 { "Direct", -1 },
2104 { "Via Track list", -1 } 2136 { "Via Track list", -1 }
2105 }; 2137 };
2138 static const struct opt_items backlight_options[] = {
2139 { "Always On", -1 },
2140 { "Normal", -1 },
2141 };
2106 2142
2107 do { 2143 do {
2108 selection=rb->do_menu(&settings_menu,&selection, NULL, true); 2144 selection=rb->do_menu(&settings_menu,&selection, NULL, true);
@@ -2161,7 +2197,10 @@ int settings_menu(void)
2161 break; 2197 break;
2162 case 8: 2198 case 8:
2163 rb->set_option("WPS Integration", &auto_wps, INT, wps_options, 3, NULL); 2199 rb->set_option("WPS Integration", &auto_wps, INT, wps_options, 3, NULL);
2164 break; 2200 break;
2201 case 9:
2202 rb->set_option("Backlight", &backlight_mode, INT, backlight_options, 2, NULL);
2203 break;
2165 2204
2166 case MENU_ATTACHED_USB: 2205 case MENU_ATTACHED_USB:
2167 return PLUGIN_USB_CONNECTED; 2206 return PLUGIN_USB_CONNECTED;
@@ -2177,6 +2216,7 @@ int settings_menu(void)
2177enum { 2216enum {
2178 PF_GOTO_WPS, 2217 PF_GOTO_WPS,
2179#if PF_PLAYBACK_CAPABLE 2218#if PF_PLAYBACK_CAPABLE
2219 PF_MENU_CLEAR_PLAYLIST,
2180 PF_MENU_PLAYBACK_CONTROL, 2220 PF_MENU_PLAYBACK_CONTROL,
2181#endif 2221#endif
2182 PF_MENU_SETTINGS, 2222 PF_MENU_SETTINGS,
@@ -2196,7 +2236,7 @@ int main_menu(void)
2196 MENUITEM_STRINGLIST(main_menu,"PictureFlow Main Menu",NULL, 2236 MENUITEM_STRINGLIST(main_menu,"PictureFlow Main Menu",NULL,
2197 "Go to WPS", 2237 "Go to WPS",
2198#if PF_PLAYBACK_CAPABLE 2238#if PF_PLAYBACK_CAPABLE
2199 "Playback Control", 2239 "Clear playlist", "Playback Control",
2200#endif 2240#endif
2201 "Settings", "Return", "Quit"); 2241 "Settings", "Return", "Quit");
2202 while (1) { 2242 while (1) {
@@ -2204,6 +2244,12 @@ int main_menu(void)
2204 case PF_GOTO_WPS: /* WPS */ 2244 case PF_GOTO_WPS: /* WPS */
2205 return -2; 2245 return -2;
2206#if PF_PLAYBACK_CAPABLE 2246#if PF_PLAYBACK_CAPABLE
2247 case PF_MENU_CLEAR_PLAYLIST:
2248 if(rb->playlist_remove_all_tracks(NULL) == 0) {
2249 rb->playlist_create(NULL, NULL);
2250 rb->splash(HZ*2, "Playlist Cleared");
2251 }
2252 break;
2207 case PF_MENU_PLAYBACK_CONTROL: /* Playback Control */ 2253 case PF_MENU_PLAYBACK_CONTROL: /* Playback Control */
2208 playback_control(NULL); 2254 playback_control(NULL);
2209 break; 2255 break;
@@ -2533,6 +2579,10 @@ int main(void)
2533 configfile_load(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION); 2579 configfile_load(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION);
2534 if(auto_wps == 0) 2580 if(auto_wps == 0)
2535 draw_splashscreen(); 2581 draw_splashscreen();
2582 if(backlight_mode == 0) {
2583 /* Turn off backlight timeout */
2584 backlight_force_on(); /* backlight control in lib/helper.c */
2585 }
2536 2586
2537 init_reflect_table(); 2587 init_reflect_table();
2538 2588
@@ -2808,8 +2858,6 @@ enum plugin_status plugin_start(const void *parameter)
2808 2858
2809 FOR_NB_SCREENS(i) 2859 FOR_NB_SCREENS(i)
2810 rb->viewportmanager_theme_enable(i, false, NULL); 2860 rb->viewportmanager_theme_enable(i, false, NULL);
2811 /* Turn off backlight timeout */
2812 backlight_force_on(); /* backlight control in lib/helper.c */
2813#ifdef HAVE_ADJUSTABLE_CPU_FREQ 2861#ifdef HAVE_ADJUSTABLE_CPU_FREQ
2814 rb->cpu_boost(true); 2862 rb->cpu_boost(true);
2815#endif 2863#endif