Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

filetypes.c clean-up

make icon a voice struct one

Change-Id: I44df788d03e38fe1bca7ea50f32c8dc5941405ab

authored by

William Wilgus and committed by
William Wilgus
1561b4ec dc47bf8a

+45 -79
+42 -71
apps/filetypes.c
··· 148 148 #endif 149 149 }; 150 150 151 - /* a table for the known file types voice clips */ 152 - static const struct fileattr_voice inbuilt_attrvoices[] = { 153 - { FILE_ATTR_AUDIO, VOICE_EXT_MPA }, 154 - { FILE_ATTR_M3U, LANG_PLAYLIST }, 155 - { FILE_ATTR_CFG, VOICE_EXT_CFG }, 156 - { FILE_ATTR_WPS, VOICE_EXT_WPS }, 157 - #ifdef HAVE_REMOTE_LCD 158 - { FILE_ATTR_RWPS, VOICE_EXT_RWPS }, 159 - #endif 160 - #if CONFIG_TUNER 161 - { FILE_ATTR_FMR, LANG_FMR }, 162 - { FILE_ATTR_FMS, VOICE_EXT_FMS }, 163 - #endif 164 - { FILE_ATTR_LNG, LANG_LANGUAGE }, 165 - { FILE_ATTR_ROCK, VOICE_EXT_ROCK }, 166 - { FILE_ATTR_LUA, VOICE_EXT_ROCK }, 167 - { FILE_ATTR_OPX, VOICE_EXT_ROCK }, 168 - { FILE_ATTR_FONT, VOICE_EXT_FONT }, 169 - { FILE_ATTR_KBD, VOICE_EXT_KBD }, 170 - { FILE_ATTR_BMARK, VOICE_EXT_BMARK }, 171 - { FILE_ATTR_CUE, VOICE_EXT_CUESHEET }, 172 - { FILE_ATTR_SBS, VOICE_EXT_SBS }, 173 - #ifdef HAVE_REMOTE_LCD 174 - { FILE_ATTR_RSBS, VOICE_EXT_RSBS }, 175 - #if CONFIG_TUNER 176 - { FILE_ATTR_RFMS, VOICE_EXT_RFMS }, 177 - #endif 178 - #endif 179 - #if defined(BOOTFILE_EXT) || defined(BOOTFILE_EXT2) 180 - { FILE_ATTR_MOD, VOICE_EXT_AJZ }, 181 - #endif 182 - }; 183 - 184 - struct attr_icon { 185 - uint16_t tree_attr; 151 + struct fileattr_icon_voice { 152 + int tree_attr; 186 153 uint16_t icon; 154 + uint16_t voiceclip; 187 155 }; 188 156 189 - /* a table for the known file type icons */ 190 - static const struct attr_icon inbuilt_attricons[] = { 191 - { FILE_ATTR_AUDIO, Icon_Audio}, 192 - { FILE_ATTR_M3U, Icon_Playlist}, 193 - { FILE_ATTR_CFG, Icon_Config}, 194 - { FILE_ATTR_WPS, Icon_Wps}, 157 + /* a table for the known file types icons & voice clips */ 158 + static const struct fileattr_icon_voice inbuilt_attr_icons_voices[] = { 159 + { FILE_ATTR_AUDIO, Icon_Audio, VOICE_EXT_MPA }, 160 + { FILE_ATTR_M3U, Icon_Playlist, LANG_PLAYLIST }, 161 + { FILE_ATTR_CFG, Icon_Config, VOICE_EXT_CFG }, 162 + { FILE_ATTR_WPS, Icon_Wps, VOICE_EXT_WPS }, 195 163 #ifdef HAVE_REMOTE_LCD 196 - { FILE_ATTR_RWPS, Icon_Wps}, 164 + {FILE_ATTR_RWPS, Icon_Wps, VOICE_EXT_RWPS }, 197 165 #endif 198 166 #if CONFIG_TUNER 199 - { FILE_ATTR_FMR, Icon_Preset}, 200 - { FILE_ATTR_FMS, Icon_Wps}, 167 + { FILE_ATTR_FMR, Icon_Preset, LANG_FMR }, 168 + { FILE_ATTR_FMS, Icon_Wps, VOICE_EXT_FMS }, 201 169 #endif 202 - { FILE_ATTR_LNG, Icon_Language}, 203 - { FILE_ATTR_ROCK, Icon_Plugin}, 204 - { FILE_ATTR_LUA, Icon_Plugin}, 205 - { FILE_ATTR_OPX, Icon_Plugin}, 206 - { FILE_ATTR_FONT, Icon_Font}, 207 - { FILE_ATTR_KBD, Icon_Keyboard}, 208 - { FILE_ATTR_BMARK, Icon_Bookmark}, 209 - { FILE_ATTR_CUE, Icon_Bookmark}, 210 - { FILE_ATTR_SBS, Icon_Wps}, 170 + { FILE_ATTR_LNG, Icon_Language, LANG_LANGUAGE }, 171 + { FILE_ATTR_ROCK, Icon_Plugin, VOICE_EXT_ROCK }, 172 + { FILE_ATTR_LUA, Icon_Plugin, VOICE_EXT_ROCK }, 173 + { FILE_ATTR_OPX, Icon_Plugin, VOICE_EXT_ROCK }, 174 + { FILE_ATTR_FONT, Icon_Font, VOICE_EXT_FONT }, 175 + { FILE_ATTR_KBD, Icon_Keyboard, VOICE_EXT_KBD }, 176 + { FILE_ATTR_BMARK, Icon_Bookmark, VOICE_EXT_BMARK }, 177 + { FILE_ATTR_CUE, Icon_Bookmark, VOICE_EXT_CUESHEET }, 178 + { FILE_ATTR_SBS, Icon_Wps, VOICE_EXT_SBS }, 211 179 #ifdef HAVE_REMOTE_LCD 212 - { FILE_ATTR_RSBS, Icon_Wps}, 180 + { FILE_ATTR_RSBS, Icon_Wps, VOICE_EXT_RSBS }, 213 181 #if CONFIG_TUNER 214 - { FILE_ATTR_RFMS, Icon_Wps}, 182 + { FILE_ATTR_RFMS, Icon_Wps, VOICE_EXT_RFMS }, 215 183 #endif 216 184 #endif 217 185 #if defined(BOOTFILE_EXT) || defined(BOOTFILE_EXT2) 218 - { FILE_ATTR_MOD, Icon_Firmware}, 186 + { FILE_ATTR_MOD, Icon_Firmware, VOICE_EXT_AJZ }, 219 187 #endif 220 188 }; 221 189 ··· 225 193 *count = sizeof(inbuilt_filetypes) / sizeof(*inbuilt_filetypes); 226 194 } 227 195 228 - long tree_filetype_voiceclip(int attr) 196 + long tree_get_filetype_voiceclip(int attr) 229 197 { 230 - logf("%s attr %d", __func__, attr); 231 - int j; 232 198 if (global_settings.talk_filetype) 233 199 { 234 - int count = sizeof(inbuilt_attrvoices)/sizeof(*inbuilt_attrvoices); 200 + size_t count = ARRAY_SIZE(inbuilt_attr_icons_voices); 235 201 /* try to find a voice ID for the extension, if known */ 236 202 attr &= FILE_ATTR_MASK; /* file type */ 237 - for (j=0; j<count; j++) 238 - if (attr == inbuilt_attrvoices[j].tree_attr) 203 + 204 + for (size_t i = count - 1; i < count; i--) 205 + { 206 + if (attr == inbuilt_attr_icons_voices[i].tree_attr) 239 207 { 240 - logf("%s attr %d id %d", __func__, attr, inbuilt_attrvoices[j].voiceclip); 241 - return inbuilt_attrvoices[j].voiceclip; 208 + logf("%s found attr %d id %d", __func__, attr, 209 + inbuilt_attr_icons_voices[i].voiceclip); 210 + return inbuilt_attr_icons_voices[i].voiceclip; 242 211 } 212 + } 243 213 } 214 + logf("%s not found attr %d", __func__, attr); 244 215 return -1; 245 216 } 246 217 ··· 489 460 490 461 static void read_builtin_types(void) 491 462 { 492 - int i,j, tree_attr; 493 - int count = sizeof(inbuilt_filetypes)/sizeof(*inbuilt_filetypes); 494 - int icon_count = sizeof(inbuilt_attricons)/sizeof(*inbuilt_attricons); 495 - for(i=0; i<count && (filetype_count < MAX_FILETYPES); i++) 463 + int tree_attr; 464 + size_t count = ARRAY_SIZE(inbuilt_filetypes); 465 + size_t icon_count = ARRAY_SIZE(inbuilt_attr_icons_voices); 466 + for(size_t i = 0; (i < count) && (filetype_count < MAX_FILETYPES); i++) 496 467 { 497 468 filetypes[filetype_count].extension = inbuilt_filetypes[i].extension; 498 469 filetypes[filetype_count].plugin = NULL; ··· 503 474 highest_attr = filetypes[filetype_count].attr; 504 475 505 476 filetypes[filetype_count].icon = unknown_file.icon; 506 - for (j = 0; j < icon_count; j++) 477 + for (size_t j = icon_count - 1; j < icon_count; j--) 507 478 { 508 - if (tree_attr == inbuilt_attricons[j].tree_attr) 479 + if (tree_attr == inbuilt_attr_icons_voices[j].tree_attr) 509 480 { 510 - filetypes[filetype_count].icon = inbuilt_attricons[j].icon; 481 + filetypes[filetype_count].icon = inbuilt_attr_icons_voices[j].icon; 511 482 break; 512 483 } 513 484 }
+1 -6
apps/filetypes.h
··· 55 55 int tree_attr; 56 56 }; 57 57 58 - struct fileattr_voice { 59 - int tree_attr; 60 - int voiceclip; 61 - }; 62 - 63 58 void tree_get_filetypes(const struct filetype**, int*) INIT_ATTR; 64 - long tree_filetype_voiceclip(int attr) INIT_ATTR; 59 + long tree_get_filetype_voiceclip(int attr) INIT_ATTR; 65 60 66 61 /* init the filetypes structs. 67 62 uses audio buffer for storage, so call early in init... */
+2 -2
apps/tree.c
··· 1188 1188 1189 1189 static void say_filetype(int attr) 1190 1190 { 1191 - talk_id(tree_filetype_voiceclip(attr), true); 1191 + talk_id(tree_get_filetype_voiceclip(attr), true); 1192 1192 } 1193 1193 1194 1194 static int ft_play_dirname(char* name) ··· 1206 1206 file_thumbnail_ext)) 1207 1207 /* file has no .talk extension */ 1208 1208 return talk_file(dir, NULL, file, file_thumbnail_ext, 1209 - TALK_IDARRAY(tree_filetype_voiceclip(attr)), false); 1209 + TALK_IDARRAY(tree_get_filetype_voiceclip(attr)), false); 1210 1210 1211 1211 /* it already is a .talk file, play this directly, but prefix it. */ 1212 1212 return talk_file(dir, NULL, file, NULL,