mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-10-14 02:27:39 -04:00
filetypes.c clean-up
make icon a voice struct one Change-Id: I44df788d03e38fe1bca7ea50f32c8dc5941405ab
This commit is contained in:
parent
dc47bf8ae2
commit
1561b4ec9a
3 changed files with 45 additions and 79 deletions
113
apps/filetypes.c
113
apps/filetypes.c
|
@ -148,74 +148,42 @@ static const struct filetype inbuilt_filetypes[] = {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
/* a table for the known file types voice clips */
|
struct fileattr_icon_voice {
|
||||||
static const struct fileattr_voice inbuilt_attrvoices[] = {
|
int tree_attr;
|
||||||
{ FILE_ATTR_AUDIO, VOICE_EXT_MPA },
|
|
||||||
{ FILE_ATTR_M3U, LANG_PLAYLIST },
|
|
||||||
{ FILE_ATTR_CFG, VOICE_EXT_CFG },
|
|
||||||
{ FILE_ATTR_WPS, VOICE_EXT_WPS },
|
|
||||||
#ifdef HAVE_REMOTE_LCD
|
|
||||||
{ FILE_ATTR_RWPS, VOICE_EXT_RWPS },
|
|
||||||
#endif
|
|
||||||
#if CONFIG_TUNER
|
|
||||||
{ FILE_ATTR_FMR, LANG_FMR },
|
|
||||||
{ FILE_ATTR_FMS, VOICE_EXT_FMS },
|
|
||||||
#endif
|
|
||||||
{ FILE_ATTR_LNG, LANG_LANGUAGE },
|
|
||||||
{ FILE_ATTR_ROCK, VOICE_EXT_ROCK },
|
|
||||||
{ FILE_ATTR_LUA, VOICE_EXT_ROCK },
|
|
||||||
{ FILE_ATTR_OPX, VOICE_EXT_ROCK },
|
|
||||||
{ FILE_ATTR_FONT, VOICE_EXT_FONT },
|
|
||||||
{ FILE_ATTR_KBD, VOICE_EXT_KBD },
|
|
||||||
{ FILE_ATTR_BMARK, VOICE_EXT_BMARK },
|
|
||||||
{ FILE_ATTR_CUE, VOICE_EXT_CUESHEET },
|
|
||||||
{ FILE_ATTR_SBS, VOICE_EXT_SBS },
|
|
||||||
#ifdef HAVE_REMOTE_LCD
|
|
||||||
{ FILE_ATTR_RSBS, VOICE_EXT_RSBS },
|
|
||||||
#if CONFIG_TUNER
|
|
||||||
{ FILE_ATTR_RFMS, VOICE_EXT_RFMS },
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
#if defined(BOOTFILE_EXT) || defined(BOOTFILE_EXT2)
|
|
||||||
{ FILE_ATTR_MOD, VOICE_EXT_AJZ },
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
struct attr_icon {
|
|
||||||
uint16_t tree_attr;
|
|
||||||
uint16_t icon;
|
uint16_t icon;
|
||||||
|
uint16_t voiceclip;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* a table for the known file type icons */
|
/* a table for the known file types icons & voice clips */
|
||||||
static const struct attr_icon inbuilt_attricons[] = {
|
static const struct fileattr_icon_voice inbuilt_attr_icons_voices[] = {
|
||||||
{ FILE_ATTR_AUDIO, Icon_Audio},
|
{ FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA },
|
||||||
{ FILE_ATTR_M3U, Icon_Playlist},
|
{ FILE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST },
|
||||||
{ FILE_ATTR_CFG, Icon_Config},
|
{ FILE_ATTR_CFG, Icon_Config, VOICE_EXT_CFG },
|
||||||
{ FILE_ATTR_WPS, Icon_Wps},
|
{ FILE_ATTR_WPS, Icon_Wps, VOICE_EXT_WPS },
|
||||||
#ifdef HAVE_REMOTE_LCD
|
#ifdef HAVE_REMOTE_LCD
|
||||||
{ FILE_ATTR_RWPS, Icon_Wps},
|
{FILE_ATTR_RWPS, Icon_Wps, VOICE_EXT_RWPS },
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_TUNER
|
#if CONFIG_TUNER
|
||||||
{ FILE_ATTR_FMR, Icon_Preset},
|
{ FILE_ATTR_FMR, Icon_Preset, LANG_FMR },
|
||||||
{ FILE_ATTR_FMS, Icon_Wps},
|
{ FILE_ATTR_FMS, Icon_Wps, VOICE_EXT_FMS },
|
||||||
#endif
|
#endif
|
||||||
{ FILE_ATTR_LNG, Icon_Language},
|
{ FILE_ATTR_LNG, Icon_Language, LANG_LANGUAGE },
|
||||||
{ FILE_ATTR_ROCK, Icon_Plugin},
|
{ FILE_ATTR_ROCK, Icon_Plugin, VOICE_EXT_ROCK },
|
||||||
{ FILE_ATTR_LUA, Icon_Plugin},
|
{ FILE_ATTR_LUA, Icon_Plugin, VOICE_EXT_ROCK },
|
||||||
{ FILE_ATTR_OPX, Icon_Plugin},
|
{ FILE_ATTR_OPX, Icon_Plugin, VOICE_EXT_ROCK },
|
||||||
{ FILE_ATTR_FONT, Icon_Font},
|
{ FILE_ATTR_FONT, Icon_Font, VOICE_EXT_FONT },
|
||||||
{ FILE_ATTR_KBD, Icon_Keyboard},
|
{ FILE_ATTR_KBD, Icon_Keyboard, VOICE_EXT_KBD },
|
||||||
{ FILE_ATTR_BMARK, Icon_Bookmark},
|
{ FILE_ATTR_BMARK, Icon_Bookmark, VOICE_EXT_BMARK },
|
||||||
{ FILE_ATTR_CUE, Icon_Bookmark},
|
{ FILE_ATTR_CUE, Icon_Bookmark, VOICE_EXT_CUESHEET },
|
||||||
{ FILE_ATTR_SBS, Icon_Wps},
|
{ FILE_ATTR_SBS, Icon_Wps, VOICE_EXT_SBS },
|
||||||
#ifdef HAVE_REMOTE_LCD
|
#ifdef HAVE_REMOTE_LCD
|
||||||
{ FILE_ATTR_RSBS, Icon_Wps},
|
{ FILE_ATTR_RSBS, Icon_Wps, VOICE_EXT_RSBS },
|
||||||
#if CONFIG_TUNER
|
#if CONFIG_TUNER
|
||||||
{ FILE_ATTR_RFMS, Icon_Wps},
|
{ FILE_ATTR_RFMS, Icon_Wps, VOICE_EXT_RFMS },
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#if defined(BOOTFILE_EXT) || defined(BOOTFILE_EXT2)
|
#if defined(BOOTFILE_EXT) || defined(BOOTFILE_EXT2)
|
||||||
{ FILE_ATTR_MOD, Icon_Firmware},
|
{ FILE_ATTR_MOD, Icon_Firmware, VOICE_EXT_AJZ },
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -225,22 +193,25 @@ void tree_get_filetypes(const struct filetype** types, int* count)
|
||||||
*count = sizeof(inbuilt_filetypes) / sizeof(*inbuilt_filetypes);
|
*count = sizeof(inbuilt_filetypes) / sizeof(*inbuilt_filetypes);
|
||||||
}
|
}
|
||||||
|
|
||||||
long tree_filetype_voiceclip(int attr)
|
long tree_get_filetype_voiceclip(int attr)
|
||||||
{
|
{
|
||||||
logf("%s attr %d", __func__, attr);
|
|
||||||
int j;
|
|
||||||
if (global_settings.talk_filetype)
|
if (global_settings.talk_filetype)
|
||||||
{
|
{
|
||||||
int count = sizeof(inbuilt_attrvoices)/sizeof(*inbuilt_attrvoices);
|
size_t count = ARRAY_SIZE(inbuilt_attr_icons_voices);
|
||||||
/* try to find a voice ID for the extension, if known */
|
/* try to find a voice ID for the extension, if known */
|
||||||
attr &= FILE_ATTR_MASK; /* file type */
|
attr &= FILE_ATTR_MASK; /* file type */
|
||||||
for (j=0; j<count; j++)
|
|
||||||
if (attr == inbuilt_attrvoices[j].tree_attr)
|
for (size_t i = count - 1; i < count; i--)
|
||||||
{
|
{
|
||||||
logf("%s attr %d id %d", __func__, attr, inbuilt_attrvoices[j].voiceclip);
|
if (attr == inbuilt_attr_icons_voices[i].tree_attr)
|
||||||
return inbuilt_attrvoices[j].voiceclip;
|
{
|
||||||
|
logf("%s found attr %d id %d", __func__, attr,
|
||||||
|
inbuilt_attr_icons_voices[i].voiceclip);
|
||||||
|
return inbuilt_attr_icons_voices[i].voiceclip;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
logf("%s not found attr %d", __func__, attr);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,10 +460,10 @@ static void rm_whitespaces(char* str)
|
||||||
|
|
||||||
static void read_builtin_types(void)
|
static void read_builtin_types(void)
|
||||||
{
|
{
|
||||||
int i,j, tree_attr;
|
int tree_attr;
|
||||||
int count = sizeof(inbuilt_filetypes)/sizeof(*inbuilt_filetypes);
|
size_t count = ARRAY_SIZE(inbuilt_filetypes);
|
||||||
int icon_count = sizeof(inbuilt_attricons)/sizeof(*inbuilt_attricons);
|
size_t icon_count = ARRAY_SIZE(inbuilt_attr_icons_voices);
|
||||||
for(i=0; i<count && (filetype_count < MAX_FILETYPES); i++)
|
for(size_t 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;
|
||||||
|
@ -503,11 +474,11 @@ static void read_builtin_types(void)
|
||||||
highest_attr = filetypes[filetype_count].attr;
|
highest_attr = filetypes[filetype_count].attr;
|
||||||
|
|
||||||
filetypes[filetype_count].icon = unknown_file.icon;
|
filetypes[filetype_count].icon = unknown_file.icon;
|
||||||
for (j = 0; j < icon_count; j++)
|
for (size_t j = icon_count - 1; j < icon_count; j--)
|
||||||
{
|
{
|
||||||
if (tree_attr == inbuilt_attricons[j].tree_attr)
|
if (tree_attr == inbuilt_attr_icons_voices[j].tree_attr)
|
||||||
{
|
{
|
||||||
filetypes[filetype_count].icon = inbuilt_attricons[j].icon;
|
filetypes[filetype_count].icon = inbuilt_attr_icons_voices[j].icon;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,13 +55,8 @@ struct filetype {
|
||||||
int tree_attr;
|
int tree_attr;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct fileattr_voice {
|
|
||||||
int tree_attr;
|
|
||||||
int voiceclip;
|
|
||||||
};
|
|
||||||
|
|
||||||
void tree_get_filetypes(const struct filetype**, int*) INIT_ATTR;
|
void tree_get_filetypes(const struct filetype**, int*) INIT_ATTR;
|
||||||
long tree_filetype_voiceclip(int attr) INIT_ATTR;
|
long tree_get_filetype_voiceclip(int attr) INIT_ATTR;
|
||||||
|
|
||||||
/* init the filetypes structs.
|
/* init the filetypes structs.
|
||||||
uses audio buffer for storage, so call early in init... */
|
uses audio buffer for storage, so call early in init... */
|
||||||
|
|
|
@ -1188,7 +1188,7 @@ bool bookmark_play(char *resume_file, int index, unsigned long elapsed,
|
||||||
|
|
||||||
static void say_filetype(int attr)
|
static void say_filetype(int attr)
|
||||||
{
|
{
|
||||||
talk_id(tree_filetype_voiceclip(attr), true);
|
talk_id(tree_get_filetype_voiceclip(attr), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ft_play_dirname(char* name)
|
static int ft_play_dirname(char* name)
|
||||||
|
@ -1206,7 +1206,7 @@ static int ft_play_filename(char *dir, char *file, int attr)
|
||||||
file_thumbnail_ext))
|
file_thumbnail_ext))
|
||||||
/* file has no .talk extension */
|
/* file has no .talk extension */
|
||||||
return talk_file(dir, NULL, file, file_thumbnail_ext,
|
return talk_file(dir, NULL, file, file_thumbnail_ext,
|
||||||
TALK_IDARRAY(tree_filetype_voiceclip(attr)), false);
|
TALK_IDARRAY(tree_get_filetype_voiceclip(attr)), false);
|
||||||
|
|
||||||
/* it already is a .talk file, play this directly, but prefix it. */
|
/* it already is a .talk file, play this directly, but prefix it. */
|
||||||
return talk_file(dir, NULL, file, NULL,
|
return talk_file(dir, NULL, file, NULL,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue