1
0
Fork 0
forked from len0rd/rockbox

jpeg,png: Change "Off: Quit." to "Show Menu: Quit." so that the message is less confusable.

fix bug plug_buf is always false in simulator even when plugin buffer is used.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24093 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Teruaki Kawashima 2009-12-21 15:20:33 +00:00
parent a2fc641570
commit 8ef2248f7c
2 changed files with 30 additions and 33 deletions

View file

@ -181,8 +181,10 @@ static int curfile = 0, direction = DIR_NONE, entries = 0;
/* list of the jpeg files */ /* list of the jpeg files */
static char **file_pt; static char **file_pt;
#if PLUGIN_BUFFER_SIZE >= MIN_MEM
/* are we using the plugin buffer or the audio buffer? */ /* are we using the plugin buffer or the audio buffer? */
bool plug_buf = false; static bool plug_buf = true;
#endif
/************************* Implementation ***************************/ /************************* Implementation ***************************/
@ -980,7 +982,7 @@ int load_and_show(char* filename)
rb->lcd_puts(0,2,"Zoom In: Stop playback."); rb->lcd_puts(0,2,"Zoom In: Stop playback.");
if(entries>1) if(entries>1)
rb->lcd_puts(0,3,"Left/Right: Skip File."); rb->lcd_puts(0,3,"Left/Right: Skip File.");
rb->lcd_puts(0,4,"Off: Quit."); rb->lcd_puts(0,4,"Show Menu: Quit.");
rb->lcd_update(); rb->lcd_update();
rb->lcd_setfont(FONT_UI); rb->lcd_setfont(FONT_UI);
@ -1159,10 +1161,11 @@ enum plugin_status plugin_start(const void* parameter)
if(!entries) return PLUGIN_ERROR; if(!entries) return PLUGIN_ERROR;
#if (PLUGIN_BUFFER_SIZE >= MIN_MEM) && !defined(SIMULATOR) #if (PLUGIN_BUFFER_SIZE >= MIN_MEM) && !defined(SIMULATOR)
if(rb->audio_status()) if(!rb->audio_status())
plug_buf = true; {
else plug_buf = false;
buf = rb->plugin_get_audio_buffer((size_t *)&buf_size); buf = rb->plugin_get_audio_buffer((size_t *)&buf_size);
}
#endif #endif
#ifdef USEGSLIB #ifdef USEGSLIB

View file

@ -146,6 +146,15 @@ typedef struct LodePNG_Decoder
#define VERSION_STRING "20080927" #define VERSION_STRING "20080927"
/* Min memory allowing us to use the plugin buffer
* and thus not stopping the music
* *Very* rough estimation:
* Max 10 000 dir entries * 4bytes/entry (char **) = 40000 bytes
* + 30k code size = 70 000
* + 50k min for png = 130 000
*/
#define MIN_MEM 130000
/* Headings */ /* Headings */
#define DIR_PREV 1 #define DIR_PREV 1
#define DIR_NEXT -1 #define DIR_NEXT -1
@ -165,21 +174,13 @@ static size_t memory_size;
static unsigned char *image; /* where we put the content of the file */ static unsigned char *image; /* where we put the content of the file */
static size_t image_size; static size_t image_size;
#if LCD_DEPTH >= 8
static fb_data *converted_image __attribute__ ((aligned (16))); /* the (color) converted image */
#else
static fb_data *converted_image; /* the (color) converted image */ static fb_data *converted_image; /* the (color) converted image */
#endif
static size_t converted_image_size; static size_t converted_image_size;
static unsigned char *decoded_image; /* the decoded image */ static unsigned char *decoded_image; /* the decoded image */
static size_t decoded_image_size; static size_t decoded_image_size;
#if LCD_DEPTH >= 8
static fb_data *resized_image __attribute__ ((aligned (16))); /* the decoded image */
#else
static fb_data *resized_image; /* the decoded image */ static fb_data *resized_image; /* the decoded image */
#endif
static struct tree_context *tree; static struct tree_context *tree;
@ -189,10 +190,12 @@ static int curfile = 0, direction = DIR_NONE, entries = 0;
static LodePNG_Decoder decoder; static LodePNG_Decoder decoder;
/* list of the jpeg files */ /* list of the png files */
static char **file_pt; static char **file_pt;
#if PLUGIN_BUFFER_SIZE >= MIN_MEM
/* are we using the plugin buffer or the audio buffer? */ /* are we using the plugin buffer or the audio buffer? */
bool plug_buf = false; static bool plug_buf = true;
#endif
/* Persistent configuration */ /* Persistent configuration */
#define PNG_CONFIGFILE "png.cfg" #define PNG_CONFIGFILE "png.cfg"
@ -226,15 +229,6 @@ static struct configdata png_config[] =
static fb_data* old_backdrop; static fb_data* old_backdrop;
#endif #endif
/* Min memory allowing us to use the plugin buffer
* and thus not stopping the music
* *Very* rough estimation:
* Max 10 000 dir entries * 4bytes/entry (char **) = 40000 bytes
* + 30k code size = 70 000
* + 50k min for png = 130 000
*/
#define MIN_MEM 130000
static int slideshow_enabled = false; /* run slideshow */ static int slideshow_enabled = false; /* run slideshow */
static int running_slideshow = false; /* loading image because of slideshw */ static int running_slideshow = false; /* loading image because of slideshw */
#ifndef SIMULATOR #ifndef SIMULATOR
@ -1823,8 +1817,7 @@ int load_image(char* filename, struct LodePNG_Decoder* decoder)
fd = rb->open(filename, O_RDONLY); fd = rb->open(filename, O_RDONLY);
if (fd < 0) if (fd < 0)
{ {
rb->snprintf(print,sizeof(print),"err opening %s:%d",filename,fd); rb->splashf(HZ, "err opening %s:%d", filename, fd);
rb->splash(HZ, print);
return PLUGIN_ERROR; return PLUGIN_ERROR;
} }
image_size = rb->filesize(fd); image_size = rb->filesize(fd);
@ -1913,9 +1906,11 @@ int load_image(char* filename, struct LodePNG_Decoder* decoder)
} }
if (decoder->error) { if (decoder->error) {
if (decoder->error == FILE_TOO_LARGE || decoder->error == OUT_OF_MEMORY #if PLUGIN_BUFFER_SIZE >= MIN_MEM
|| decoder->error == Z_MEM_ERROR) if (plug_buf && (decoder->error == FILE_TOO_LARGE
|| decoder->error == OUT_OF_MEMORY || decoder->error == Z_MEM_ERROR))
return PLUGIN_OUTOFMEM; return PLUGIN_OUTOFMEM;
#endif
if (decoder->error >= PNG_ERROR_MIN && decoder->error <= PNG_ERROR_MAX if (decoder->error >= PNG_ERROR_MIN && decoder->error <= PNG_ERROR_MAX
&& png_error_messages[decoder->error-PNG_ERROR_MIN] != NULL) && png_error_messages[decoder->error-PNG_ERROR_MIN] != NULL)
@ -2070,7 +2065,7 @@ int load_and_show(char* filename)
rb->lcd_puts(0,2,"Zoom In: Stop playback."); rb->lcd_puts(0,2,"Zoom In: Stop playback.");
if (entries>1) if (entries>1)
rb->lcd_puts(0,3,"Left/Right: Skip File."); rb->lcd_puts(0,3,"Left/Right: Skip File.");
rb->lcd_puts(0,4,"Off: Quit."); rb->lcd_puts(0,4,"Show Menu: Quit.");
rb->lcd_update(); rb->lcd_update();
rb->lcd_setfont(FONT_UI); rb->lcd_setfont(FONT_UI);
@ -2144,7 +2139,7 @@ int load_and_show(char* filename)
ds_max = ds_min; ds_max = ds_min;
} }
ds = ds_max; /* initials setting */ ds = ds_max; /* initialize setting */
cx = decoder.infoPng.width/ds/2; /* center the view */ cx = decoder.infoPng.width/ds/2; /* center the view */
cy = decoder.infoPng.height/ds/2; cy = decoder.infoPng.height/ds/2;
@ -2233,9 +2228,8 @@ enum plugin_status plugin_start(const void* parameter)
if (!entries) return PLUGIN_ERROR; if (!entries) return PLUGIN_ERROR;
#if (PLUGIN_BUFFER_SIZE >= MIN_MEM) && !defined(SIMULATOR) #if (PLUGIN_BUFFER_SIZE >= MIN_MEM) && !defined(SIMULATOR)
if (rb->audio_status()) { if (!rb->audio_status()) {
plug_buf = true; plug_buf = false;
} else {
memory = rb->plugin_get_audio_buffer((size_t *)&memory_size); memory = rb->plugin_get_audio_buffer((size_t *)&memory_size);
} }
#endif #endif