Revert my filetypes commits from today. the nvram buffer is 44bytes of which 43 are currently being used. We need to figure out what to do about this.
So in the mean time, set the MAX_FILETYPES to a huge value so we don't have to worry about this for a long while. This build shold be safe to use again. If you downloaded a build after r14286 make sure you grab a new one git-svn-id: svn://svn.rockbox.org/rockbox/trunk@14291 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
7cb80a2a70
commit
07a7d47cc1
4 changed files with 26 additions and 47 deletions
|
@ -41,12 +41,20 @@
|
||||||
#include "icons.h"
|
#include "icons.h"
|
||||||
#include "logf.h"
|
#include "logf.h"
|
||||||
|
|
||||||
|
/* max filetypes (plugins & icons stored here) */
|
||||||
|
#if CONFIG_CODEC == SWCODEC
|
||||||
|
#define MAX_FILETYPES 128
|
||||||
|
#else
|
||||||
|
#define MAX_FILETYPES 48
|
||||||
|
#endif
|
||||||
|
|
||||||
/* a table for the know file types */
|
/* a table for the know file types */
|
||||||
const struct filetype inbuilt_filetypes[] = {
|
const struct filetype inbuilt_filetypes[] = {
|
||||||
{ "mp3", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
{ "mp3", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
||||||
{ "mp2", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
{ "mp2", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
||||||
{ "mpa", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
{ "mpa", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
||||||
#if CONFIG_CODEC == SWCODEC
|
#if CONFIG_CODEC == SWCODEC
|
||||||
|
/* Temporary hack to allow playlist creation */
|
||||||
{ "mp1", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
{ "mp1", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
||||||
{ "ogg", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
{ "ogg", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
||||||
{ "wma", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
{ "wma", FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
||||||
|
@ -96,7 +104,7 @@ const struct filetype inbuilt_filetypes[] = {
|
||||||
{ "cue", FILE_ATTR_CUE, Icon_Bookmark, VOICE_EXT_CUESHEET },
|
{ "cue", FILE_ATTR_CUE, Icon_Bookmark, VOICE_EXT_CUESHEET },
|
||||||
#ifdef BOOTFILE_EXT
|
#ifdef BOOTFILE_EXT
|
||||||
{ BOOTFILE_EXT, FILE_ATTR_MOD, Icon_Firmware, VOICE_EXT_AJZ },
|
{ BOOTFILE_EXT, FILE_ATTR_MOD, Icon_Firmware, VOICE_EXT_AJZ },
|
||||||
#endif /* #ifndef BOOTFILE_EXT */
|
#endif /* #ifndef SIMULATOR */
|
||||||
};
|
};
|
||||||
|
|
||||||
void tree_get_filetypes(const struct filetype** types, int* count)
|
void tree_get_filetypes(const struct filetype** types, int* count)
|
||||||
|
@ -115,14 +123,14 @@ struct file_type {
|
||||||
char* plugin; /* Which plugin to use, NULL if unknown, or builtin */
|
char* plugin; /* Which plugin to use, NULL if unknown, or builtin */
|
||||||
char* extension; /* NULL for none */
|
char* extension; /* NULL for none */
|
||||||
};
|
};
|
||||||
static struct file_type *filetypes;
|
static struct file_type filetypes[MAX_FILETYPES];
|
||||||
static int *custom_filetype_icons;
|
static int custom_filetype_icons[MAX_FILETYPES];
|
||||||
static bool custom_icons_loaded = false;
|
static bool custom_icons_loaded = false;
|
||||||
#ifdef HAVE_LCD_COLOR
|
#ifdef HAVE_LCD_COLOR
|
||||||
static int *custom_colors;
|
static int custom_colors[MAX_FILETYPES+1];
|
||||||
#endif
|
#endif
|
||||||
|
static int filetype_count = 0;
|
||||||
static unsigned char heighest_attr = 0;
|
static unsigned char heighest_attr = 0;
|
||||||
static int max_types = 0, filetype_count;
|
|
||||||
|
|
||||||
static char *filetypes_strdup(char* string)
|
static char *filetypes_strdup(char* string)
|
||||||
{
|
{
|
||||||
|
@ -142,10 +150,7 @@ void read_color_theme_file(void) {
|
||||||
int fd;
|
int fd;
|
||||||
char *ext, *color;
|
char *ext, *color;
|
||||||
int i;
|
int i;
|
||||||
|
for (i = 0; i < MAX_FILETYPES+1; i++) {
|
||||||
if (max_types == 0)
|
|
||||||
return;
|
|
||||||
for (i = 0; i < filetype_count+1; i++) {
|
|
||||||
custom_colors[i] = -1;
|
custom_colors[i] = -1;
|
||||||
}
|
}
|
||||||
snprintf(buffer, MAX_PATH, "%s/%s.colours", THEME_DIR,
|
snprintf(buffer, MAX_PATH, "%s/%s.colours", THEME_DIR,
|
||||||
|
@ -164,7 +169,7 @@ void read_color_theme_file(void) {
|
||||||
}
|
}
|
||||||
if (!strcasecmp(ext, "???"))
|
if (!strcasecmp(ext, "???"))
|
||||||
{
|
{
|
||||||
custom_colors[filetype_count] = hex_to_rgb(color);
|
custom_colors[MAX_FILETYPES] = hex_to_rgb(color);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
for (i=1; i<filetype_count; i++)
|
for (i=1; i<filetype_count; i++)
|
||||||
|
@ -190,8 +195,6 @@ void read_viewer_theme_file(void)
|
||||||
global_status.viewer_icon_count = 0;
|
global_status.viewer_icon_count = 0;
|
||||||
custom_icons_loaded = false;
|
custom_icons_loaded = false;
|
||||||
custom_filetype_icons[0] = Icon_Folder;
|
custom_filetype_icons[0] = Icon_Folder;
|
||||||
if (max_types == 0)
|
|
||||||
return;
|
|
||||||
for (i=1; i<filetype_count; i++)
|
for (i=1; i<filetype_count; i++)
|
||||||
{
|
{
|
||||||
custom_filetype_icons[i] = filetypes[i].icon;
|
custom_filetype_icons[i] = filetypes[i].icon;
|
||||||
|
@ -233,16 +236,6 @@ void read_viewer_theme_file(void)
|
||||||
|
|
||||||
void filetype_init(void)
|
void filetype_init(void)
|
||||||
{
|
{
|
||||||
max_types = global_status.filetype_count + 8; /* always make a bit more room
|
|
||||||
for more types */
|
|
||||||
filetypes = (struct file_type *)buffer_alloc(sizeof(struct file_type)*
|
|
||||||
max_types);
|
|
||||||
custom_filetype_icons = (int*)buffer_alloc(sizeof(int)*max_types);
|
|
||||||
#ifdef HAVE_LCD_COLOR
|
|
||||||
/* the extra item here is for the unknown types
|
|
||||||
which use the last array element */
|
|
||||||
custom_colors = (int*)buffer_alloc(sizeof(int)*(max_types+1));
|
|
||||||
#endif
|
|
||||||
/* set the directory item first */
|
/* set the directory item first */
|
||||||
filetypes[0].extension = NULL;
|
filetypes[0].extension = NULL;
|
||||||
filetypes[0].plugin = NULL;
|
filetypes[0].plugin = NULL;
|
||||||
|
@ -258,10 +251,6 @@ void filetype_init(void)
|
||||||
#ifdef HAVE_LCD_COLOR
|
#ifdef HAVE_LCD_COLOR
|
||||||
read_color_theme_file();
|
read_color_theme_file();
|
||||||
#endif
|
#endif
|
||||||
if (global_status.filetype_count == 0)
|
|
||||||
global_status.filetype_count = MAX_FILETYPES;
|
|
||||||
else global_status.filetype_count = filetype_count;
|
|
||||||
status_save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove all white spaces from string */
|
/* remove all white spaces from string */
|
||||||
|
@ -283,14 +272,14 @@ static void rm_whitespaces(char* str)
|
||||||
static void read_builtin_types(void)
|
static void read_builtin_types(void)
|
||||||
{
|
{
|
||||||
int count = sizeof(inbuilt_filetypes)/sizeof(*inbuilt_filetypes), i;
|
int count = sizeof(inbuilt_filetypes)/sizeof(*inbuilt_filetypes), i;
|
||||||
for(i=0; i<count && (filetype_count<max_types); i++)
|
for(i=0; i<count && (filetype_count < MAX_FILETYPES); i++)
|
||||||
{
|
{
|
||||||
filetypes[filetype_count].extension = inbuilt_filetypes[i].extension;
|
filetypes[filetype_count].extension = inbuilt_filetypes[i].extension;
|
||||||
filetypes[filetype_count].plugin = NULL;
|
filetypes[filetype_count].plugin = NULL;
|
||||||
filetypes[filetype_count].attr = inbuilt_filetypes[i].tree_attr>>8;
|
filetypes[filetype_count].attr = inbuilt_filetypes[i].tree_attr>>8;
|
||||||
if (filetypes[filetype_count].attr > heighest_attr)
|
if (filetypes[filetype_count].attr > heighest_attr)
|
||||||
heighest_attr = filetypes[filetype_count].attr;
|
heighest_attr = filetypes[filetype_count].attr;
|
||||||
filetypes[filetype_count].icon = inbuilt_filetypes[i].icon;
|
filetypes[filetype_count].icon = inbuilt_filetypes[i].icon;
|
||||||
filetype_count++;
|
filetype_count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,15 +291,14 @@ static void read_config(char* config_file)
|
||||||
int fd = open(config_file, O_RDONLY);
|
int fd = open(config_file, O_RDONLY);
|
||||||
if (fd < 0)
|
if (fd < 0)
|
||||||
return;
|
return;
|
||||||
/* config file is in the form
|
/* config file is in the for
|
||||||
<extension>,<plugin>,<icon code>
|
<extension>,<plugin>,<icon code>
|
||||||
ignore line if either of the first two are missing */
|
ignore line if either of the first two are missing */
|
||||||
while (read_line(fd, line, 64) > 0)
|
while (read_line(fd, line, 64) > 0)
|
||||||
{
|
{
|
||||||
if (filetype_count >= max_types)
|
if (filetype_count >= MAX_FILETYPES)
|
||||||
{
|
{
|
||||||
gui_syncsplash(HZ, ID2P(LANG_FILETYPES_FULL));
|
gui_syncsplash(HZ, ID2P(LANG_FILETYPES_FULL));
|
||||||
global_status.filetype_count = 0; /* make plenty of room for next reboot */
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
rm_whitespaces(line);
|
rm_whitespaces(line);
|
||||||
|
@ -359,7 +347,7 @@ int filetype_get_attr(const char* file)
|
||||||
if (!extension)
|
if (!extension)
|
||||||
return 0;
|
return 0;
|
||||||
extension++;
|
extension++;
|
||||||
for (i=0; i<max_types; i++)
|
for (i=0; i<filetype_count; i++)
|
||||||
{
|
{
|
||||||
if (filetypes[i].extension &&
|
if (filetypes[i].extension &&
|
||||||
!strcasecmp(extension, filetypes[i].extension))
|
!strcasecmp(extension, filetypes[i].extension))
|
||||||
|
@ -391,7 +379,7 @@ int filetype_get_color(const char * name, int attr)
|
||||||
return custom_colors[0];
|
return custom_colors[0];
|
||||||
extension = strrchr(name, '.');
|
extension = strrchr(name, '.');
|
||||||
if (!extension)
|
if (!extension)
|
||||||
return custom_colors[filetype_count];
|
return custom_colors[MAX_FILETYPES];
|
||||||
extension++;
|
extension++;
|
||||||
|
|
||||||
for (i=1; i<filetype_count; i++)
|
for (i=1; i<filetype_count; i++)
|
||||||
|
@ -400,7 +388,7 @@ int filetype_get_color(const char * name, int attr)
|
||||||
!strcasecmp(extension, filetypes[i].extension))
|
!strcasecmp(extension, filetypes[i].extension))
|
||||||
return custom_colors[i];
|
return custom_colors[i];
|
||||||
}
|
}
|
||||||
return custom_colors[filetype_count];
|
return custom_colors[MAX_FILETYPES];
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -451,9 +439,9 @@ char * openwith_get_name(int selected_item, void * data, char * buffer)
|
||||||
int filetype_list_viewers(const char* current_file)
|
int filetype_list_viewers(const char* current_file)
|
||||||
{
|
{
|
||||||
int i, count = 0, action;
|
int i, count = 0, action;
|
||||||
int items[64];
|
int items[MAX_FILETYPES];
|
||||||
struct gui_synclist lists;
|
struct gui_synclist lists;
|
||||||
for (i=0; i<filetype_count && count < 64; i++)
|
for (i=0; i<filetype_count && count < MAX_FILETYPES; i++)
|
||||||
{
|
{
|
||||||
if (filetypes[i].plugin)
|
if (filetypes[i].plugin)
|
||||||
{
|
{
|
||||||
|
|
|
@ -145,13 +145,6 @@ extern const char * const trig_durations[TRIG_DURATION_COUNT];
|
||||||
#define HAVE_LCD_CONTRAST
|
#define HAVE_LCD_CONTRAST
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_CODEC == SWCODEC
|
|
||||||
#define MAX_FILETYPES 128
|
|
||||||
#else
|
|
||||||
#define MAX_FILETYPES 48
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* repeat mode options */
|
/* repeat mode options */
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -315,7 +308,6 @@ struct system_status
|
||||||
relative to MIN_FREQ */
|
relative to MIN_FREQ */
|
||||||
#endif
|
#endif
|
||||||
char last_screen;
|
char last_screen;
|
||||||
int filetype_count;
|
|
||||||
int viewer_icon_count;
|
int viewer_icon_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1256,7 +1256,6 @@ const struct settings_list settings[] = {
|
||||||
3, "list_accel_wait", UNIT_SEC, 1, 10, 1,
|
3, "list_accel_wait", UNIT_SEC, 1, 10, 1,
|
||||||
scanaccel_formatter, scanaccel_getlang, NULL),
|
scanaccel_formatter, scanaccel_getlang, NULL),
|
||||||
#endif /* HAVE_SCROLLWHEEL */
|
#endif /* HAVE_SCROLLWHEEL */
|
||||||
SYSTEM_SETTING(NVRAM(4),filetype_count, MAX_FILETYPES),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const int nb_settings = sizeof(settings)/sizeof(*settings);
|
const int nb_settings = sizeof(settings)/sizeof(*settings);
|
||||||
|
|
|
@ -96,7 +96,7 @@ struct choice_setting {
|
||||||
|
|
||||||
#define F_NVRAM_BYTES_MASK 0xE000 /*0-4 bytes can be stored */
|
#define F_NVRAM_BYTES_MASK 0xE000 /*0-4 bytes can be stored */
|
||||||
#define F_NVRAM_MASK_SHIFT 13
|
#define F_NVRAM_MASK_SHIFT 13
|
||||||
#define NVRAM_CONFIG_VERSION 3
|
#define NVRAM_CONFIG_VERSION 4
|
||||||
/* Above define should be bumped if
|
/* Above define should be bumped if
|
||||||
- a new NVRAM setting is added between 2 other NVRAM settings
|
- a new NVRAM setting is added between 2 other NVRAM settings
|
||||||
- number of bytes for a NVRAM setting is changed
|
- number of bytes for a NVRAM setting is changed
|
||||||
|
|
Loading…
Reference in a new issue