mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-09 13:12:37 -05:00
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
This commit is contained in:
parent
e02ceefdbc
commit
6efc8d5bc1
1 changed files with 73 additions and 25 deletions
|
|
@ -315,6 +315,7 @@ static int zoom = 100;
|
|||
static bool show_fps = false;
|
||||
static int auto_wps = 0;
|
||||
static int last_album = 0;
|
||||
static int backlight_mode = 0;
|
||||
static bool resize = true;
|
||||
static int cache_version = 0;
|
||||
static int show_album_name = (LCD_HEIGHT > 100)
|
||||
|
|
@ -335,7 +336,8 @@ static struct configdata config[] =
|
|||
{ TYPE_ENUM, 0, 3, { .int_p = &show_album_name }, "show album name",
|
||||
show_album_name_conf },
|
||||
{ TYPE_INT, 0, 2, { .int_p = &auto_wps }, "auto wps", NULL },
|
||||
{ TYPE_INT, 0, 999999, { .int_p = &last_album }, "last album", NULL }
|
||||
{ TYPE_INT, 0, 999999, { .int_p = &last_album }, "last album", NULL },
|
||||
{ TYPE_INT, 0, 1, { .int_p = &backlight_mode }, "backlight", NULL }
|
||||
};
|
||||
|
||||
#define CONFIG_NUM_ITEMS (sizeof(config) / sizeof(struct configdata))
|
||||
|
|
@ -888,13 +890,12 @@ retry:
|
|||
buflib_buffer_out(&buf_ctx, &out);
|
||||
avail += out;
|
||||
borrowed += out;
|
||||
if (track_count)
|
||||
{
|
||||
struct track_data *new_tracks = (struct track_data *)(out + (uintptr_t)tracks);
|
||||
unsigned int bytes = track_count * sizeof(struct track_data);
|
||||
rb->memmove(new_tracks, tracks, bytes);
|
||||
tracks = new_tracks;
|
||||
}
|
||||
|
||||
struct track_data *new_tracks = (struct track_data *)(out + (uintptr_t)tracks);
|
||||
unsigned int bytes = track_count * sizeof(struct track_data);
|
||||
if (track_count)
|
||||
rb->memmove(new_tracks, tracks, bytes);
|
||||
tracks = new_tracks;
|
||||
}
|
||||
goto retry;
|
||||
}
|
||||
|
|
@ -1051,6 +1052,24 @@ void draw_progressbar(int step)
|
|||
rb->yield();
|
||||
}
|
||||
|
||||
/* Calculate modified FNV hash of string
|
||||
* has good avalanche behaviour and uniform distribution
|
||||
* see http://home.comcast.net/~bretm/hash/ */
|
||||
unsigned int mfnv(char *str)
|
||||
{
|
||||
const unsigned int p = 16777619;
|
||||
unsigned int hash = 0x811C9DC5; // 2166136261;
|
||||
|
||||
while(*str)
|
||||
hash = (hash ^ *str++) * p;
|
||||
hash += hash << 13;
|
||||
hash ^= hash >> 7;
|
||||
hash += hash << 3;
|
||||
hash ^= hash >> 17;
|
||||
hash += hash << 5;
|
||||
return hash;
|
||||
}
|
||||
|
||||
/**
|
||||
Precomupte the album art images and store them in CACHE_PREFIX.
|
||||
*/
|
||||
|
|
@ -1064,29 +1083,35 @@ bool create_albumart_cache(void)
|
|||
char pfraw_file[MAX_PATH];
|
||||
char albumart_file[MAX_PATH];
|
||||
unsigned int format = FORMAT_NATIVE;
|
||||
bool forced = cache_version == 0;
|
||||
cache_version = 0;
|
||||
configfile_save(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION);
|
||||
if (resize)
|
||||
format |= FORMAT_RESIZE|FORMAT_KEEP_ASPECT;
|
||||
for (i=0; i < album_count; i++)
|
||||
{
|
||||
rb->snprintf(pfraw_file, sizeof(pfraw_file), CACHE_PREFIX "/%d.pfraw",
|
||||
i);
|
||||
rb->snprintf(pfraw_file, sizeof(pfraw_file), CACHE_PREFIX "/%x.pfraw",
|
||||
mfnv(get_album_name(i)));
|
||||
/* delete existing cache, so it's a true rebuild */
|
||||
if(rb->file_exists(pfraw_file))
|
||||
if(rb->file_exists(pfraw_file)) {
|
||||
if(!forced)
|
||||
continue;
|
||||
rb->remove(pfraw_file);
|
||||
}
|
||||
draw_progressbar(i);
|
||||
if (!get_albumart_for_index_from_db(i, albumart_file, MAX_PATH))
|
||||
continue;
|
||||
rb->strcpy(albumart_file, EMPTY_SLIDE_BMP);
|
||||
|
||||
input_bmp.data = buf;
|
||||
input_bmp.width = DISPLAY_WIDTH;
|
||||
input_bmp.height = DISPLAY_HEIGHT;
|
||||
ret = read_image_file(albumart_file, &input_bmp,
|
||||
buf_size, format, &format_transposed);
|
||||
ret = read_image_file(albumart_file, &input_bmp, buf_size, format, &format_transposed);
|
||||
if (ret <= 0) {
|
||||
rb->splash(HZ, "Could not read bmp");
|
||||
continue; /* skip missing/broken files */
|
||||
rb->splashf(HZ, "Album art is bad: %s", get_album_name(i));
|
||||
rb->strcpy(albumart_file, EMPTY_SLIDE_BMP);
|
||||
ret = read_image_file(albumart_file, &input_bmp, buf_size, format, &format_transposed);
|
||||
if(ret <= 0)
|
||||
continue;
|
||||
}
|
||||
if (!save_pfraw(pfraw_file, &input_bmp))
|
||||
{
|
||||
|
|
@ -1119,7 +1144,8 @@ void thread(void)
|
|||
/* we just woke up */
|
||||
break;
|
||||
}
|
||||
while ( load_new_slide() ) {
|
||||
if(ev.id != SYS_TIMEOUT)
|
||||
while ( load_new_slide() ) {
|
||||
rb->yield();
|
||||
switch (ev.id) {
|
||||
case EV_EXIT:
|
||||
|
|
@ -1361,8 +1387,10 @@ int read_pfraw(char* filename, int prio)
|
|||
{
|
||||
struct pfraw_header bmph;
|
||||
int fh = rb->open(filename, O_RDONLY);
|
||||
if( fh < 0 )
|
||||
if( fh < 0 ) {
|
||||
cache_version = 1;
|
||||
return empty_slide_hid;
|
||||
}
|
||||
else
|
||||
rb->read(fh, &bmph, sizeof(struct pfraw_header));
|
||||
|
||||
|
|
@ -1377,6 +1405,7 @@ int read_pfraw(char* filename, int prio)
|
|||
return 0;
|
||||
}
|
||||
|
||||
rb->yield(); // allow audio to play when fast scrolling
|
||||
struct dim *bm = buflib_get_data(&buf_ctx, hid);
|
||||
|
||||
bm->width = bmph.width;
|
||||
|
|
@ -1402,8 +1431,8 @@ static inline bool load_and_prepare_surface(const int slide_index,
|
|||
const int prio)
|
||||
{
|
||||
char tmp_path_name[MAX_PATH+1];
|
||||
rb->snprintf(tmp_path_name, sizeof(tmp_path_name), CACHE_PREFIX "/%d.pfraw",
|
||||
slide_index);
|
||||
rb->snprintf(tmp_path_name, sizeof(tmp_path_name), CACHE_PREFIX "/%x.pfraw",
|
||||
mfnv(get_album_name(slide_index)));
|
||||
|
||||
int hid = read_pfraw(tmp_path_name, prio);
|
||||
if (!hid)
|
||||
|
|
@ -1775,6 +1804,9 @@ void render_slide(struct slide_data *slide, const int alpha)
|
|||
pixel -= PIXELSTEP_Y;
|
||||
}
|
||||
}
|
||||
rb->yield(); // allow audio to play when fast scrolling
|
||||
bmp = surface(slide->slide_index); // resync surface due to yield
|
||||
ptr = &src[column * bmp->height];
|
||||
p = (bmp->height-DISPLAY_OFFS) * PFREAL_ONE;
|
||||
plim = MIN(sh * PFREAL_ONE, p + (LCD_HEIGHT/2) * dy);
|
||||
int plim2 = MIN(MIN(sh + REFLECT_HEIGHT, sh * 2) * PFREAL_ONE,
|
||||
|
|
@ -2091,7 +2123,7 @@ int settings_menu(void)
|
|||
MENUITEM_STRINGLIST(settings_menu, "PictureFlow Settings", NULL, "Show FPS",
|
||||
"Spacing", "Centre margin", "Number of slides", "Zoom",
|
||||
"Show album title", "Resize Covers", "Rebuild cache",
|
||||
"WPS Integration");
|
||||
"WPS Integration", "Backlight");
|
||||
|
||||
static const struct opt_items album_name_options[] = {
|
||||
{ "Hide album title", -1 },
|
||||
|
|
@ -2103,6 +2135,10 @@ int settings_menu(void)
|
|||
{ "Direct", -1 },
|
||||
{ "Via Track list", -1 }
|
||||
};
|
||||
static const struct opt_items backlight_options[] = {
|
||||
{ "Always On", -1 },
|
||||
{ "Normal", -1 },
|
||||
};
|
||||
|
||||
do {
|
||||
selection=rb->do_menu(&settings_menu,&selection, NULL, true);
|
||||
|
|
@ -2161,7 +2197,10 @@ int settings_menu(void)
|
|||
break;
|
||||
case 8:
|
||||
rb->set_option("WPS Integration", &auto_wps, INT, wps_options, 3, NULL);
|
||||
break;
|
||||
break;
|
||||
case 9:
|
||||
rb->set_option("Backlight", &backlight_mode, INT, backlight_options, 2, NULL);
|
||||
break;
|
||||
|
||||
case MENU_ATTACHED_USB:
|
||||
return PLUGIN_USB_CONNECTED;
|
||||
|
|
@ -2177,6 +2216,7 @@ int settings_menu(void)
|
|||
enum {
|
||||
PF_GOTO_WPS,
|
||||
#if PF_PLAYBACK_CAPABLE
|
||||
PF_MENU_CLEAR_PLAYLIST,
|
||||
PF_MENU_PLAYBACK_CONTROL,
|
||||
#endif
|
||||
PF_MENU_SETTINGS,
|
||||
|
|
@ -2196,7 +2236,7 @@ int main_menu(void)
|
|||
MENUITEM_STRINGLIST(main_menu,"PictureFlow Main Menu",NULL,
|
||||
"Go to WPS",
|
||||
#if PF_PLAYBACK_CAPABLE
|
||||
"Playback Control",
|
||||
"Clear playlist", "Playback Control",
|
||||
#endif
|
||||
"Settings", "Return", "Quit");
|
||||
while (1) {
|
||||
|
|
@ -2204,6 +2244,12 @@ int main_menu(void)
|
|||
case PF_GOTO_WPS: /* WPS */
|
||||
return -2;
|
||||
#if PF_PLAYBACK_CAPABLE
|
||||
case PF_MENU_CLEAR_PLAYLIST:
|
||||
if(rb->playlist_remove_all_tracks(NULL) == 0) {
|
||||
rb->playlist_create(NULL, NULL);
|
||||
rb->splash(HZ*2, "Playlist Cleared");
|
||||
}
|
||||
break;
|
||||
case PF_MENU_PLAYBACK_CONTROL: /* Playback Control */
|
||||
playback_control(NULL);
|
||||
break;
|
||||
|
|
@ -2533,6 +2579,10 @@ int main(void)
|
|||
configfile_load(CONFIG_FILE, config, CONFIG_NUM_ITEMS, CONFIG_VERSION);
|
||||
if(auto_wps == 0)
|
||||
draw_splashscreen();
|
||||
if(backlight_mode == 0) {
|
||||
/* Turn off backlight timeout */
|
||||
backlight_force_on(); /* backlight control in lib/helper.c */
|
||||
}
|
||||
|
||||
init_reflect_table();
|
||||
|
||||
|
|
@ -2808,8 +2858,6 @@ enum plugin_status plugin_start(const void *parameter)
|
|||
|
||||
FOR_NB_SCREENS(i)
|
||||
rb->viewportmanager_theme_enable(i, false, NULL);
|
||||
/* Turn off backlight timeout */
|
||||
backlight_force_on(); /* backlight control in lib/helper.c */
|
||||
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
||||
rb->cpu_boost(true);
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue