diff options
author | William Wilgus <wilgus.william@gmail.com> | 2022-12-10 14:36:39 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2022-12-13 22:35:24 -0500 |
commit | c6c1d62489b81c3568aa7d57a01c543a1c3f1f4a (patch) | |
tree | fe4234e7085c1a5130246a4d35a80e74003abf5e | |
parent | 8ff2c81bde5078ea55e1865ec980fe09bc3d5f09 (diff) | |
download | rockbox-c6c1d62489b81c3568aa7d57a01c543a1c3f1f4a.tar.gz rockbox-c6c1d62489b81c3568aa7d57a01c543a1c3f1f4a.zip |
[Bug Fix] filetypes.c move voice data out of INIT_ATTR
tree_get_filetype_voiceclip is called after init it shouldn't be marked as INIT_ATTR
add _init to the functions & data that are used at init only to be a bit more clear
Change-Id: I8eb1914560b782c2c0fdd7649e761f94e382d5cb
-rw-r--r-- | apps/filetypes.c | 26 | ||||
-rw-r--r-- | apps/filetypes.h | 4 | ||||
-rw-r--r-- | apps/tree.c | 4 |
3 files changed, 13 insertions, 21 deletions
diff --git a/apps/filetypes.c b/apps/filetypes.c index ec9bd1a7ae..03f3cfa994 100644 --- a/apps/filetypes.c +++ b/apps/filetypes.c | |||
@@ -46,6 +46,10 @@ | |||
46 | /* max viewer plugins */ | 46 | /* max viewer plugins */ |
47 | #define MAX_VIEWERS 56 | 47 | #define MAX_VIEWERS 56 |
48 | 48 | ||
49 | static void read_builtin_types_init(void) INIT_ATTR; | ||
50 | static void read_viewers_config_init(void) INIT_ATTR; | ||
51 | static void read_config_init(int fd) INIT_ATTR; | ||
52 | |||
49 | /* a table for the known file types */ | 53 | /* a table for the known file types */ |
50 | static const struct filetype inbuilt_filetypes[] = { | 54 | static const struct filetype inbuilt_filetypes[] = { |
51 | { "mp3", FILE_ATTR_AUDIO }, | 55 | { "mp3", FILE_ATTR_AUDIO }, |
@@ -187,12 +191,6 @@ static const struct fileattr_icon_voice inbuilt_attr_icons_voices[] = { | |||
187 | #endif | 191 | #endif |
188 | }; | 192 | }; |
189 | 193 | ||
190 | void tree_get_filetypes(const struct filetype** types, int* count) | ||
191 | { | ||
192 | *types = inbuilt_filetypes; | ||
193 | *count = sizeof(inbuilt_filetypes) / sizeof(*inbuilt_filetypes); | ||
194 | } | ||
195 | |||
196 | long tree_get_filetype_voiceclip(int attr) | 194 | long tree_get_filetype_voiceclip(int attr) |
197 | { | 195 | { |
198 | if (global_settings.talk_filetype) | 196 | if (global_settings.talk_filetype) |
@@ -306,8 +304,6 @@ static int find_extension(const char* extension) | |||
306 | return -1; | 304 | return -1; |
307 | } | 305 | } |
308 | 306 | ||
309 | static void read_builtin_types(void); | ||
310 | static void read_config(int fd); | ||
311 | #ifdef HAVE_LCD_COLOR | 307 | #ifdef HAVE_LCD_COLOR |
312 | /* Colors file format is similar to icons: | 308 | /* Colors file format is similar to icons: |
313 | * ext:hex_color | 309 | * ext:hex_color |
@@ -401,7 +397,7 @@ void read_viewer_theme_file(void) | |||
401 | custom_icons_loaded = true; | 397 | custom_icons_loaded = true; |
402 | } | 398 | } |
403 | 399 | ||
404 | static void read_viewers_config(void) | 400 | static void read_viewers_config_init(void) |
405 | { | 401 | { |
406 | int fd = open(VIEWERS_CONFIG, O_RDONLY); | 402 | int fd = open(VIEWERS_CONFIG, O_RDONLY); |
407 | if(fd < 0) | 403 | if(fd < 0) |
@@ -417,14 +413,14 @@ static void read_viewers_config(void) | |||
417 | if(strdup_handle <= 0) | 413 | if(strdup_handle <= 0) |
418 | goto out; | 414 | goto out; |
419 | 415 | ||
420 | read_config(fd); | 416 | read_config_init(fd); |
421 | core_shrink(strdup_handle, core_get_data(strdup_handle), strdup_cur_idx); | 417 | core_shrink(strdup_handle, core_get_data(strdup_handle), strdup_cur_idx); |
422 | 418 | ||
423 | out: | 419 | out: |
424 | close(fd); | 420 | close(fd); |
425 | } | 421 | } |
426 | 422 | ||
427 | void filetype_init(void) | 423 | void filetype_init(void) |
428 | { | 424 | { |
429 | /* set the directory item first */ | 425 | /* set the directory item first */ |
430 | filetypes[0].extension = NULL; | 426 | filetypes[0].extension = NULL; |
@@ -435,8 +431,8 @@ void filetype_init(void) | |||
435 | viewer_count = 0; | 431 | viewer_count = 0; |
436 | filetype_count = 1; | 432 | filetype_count = 1; |
437 | 433 | ||
438 | read_builtin_types(); | 434 | read_builtin_types_init(); |
439 | read_viewers_config(); | 435 | read_viewers_config_init(); |
440 | read_viewer_theme_file(); | 436 | read_viewer_theme_file(); |
441 | #ifdef HAVE_LCD_COLOR | 437 | #ifdef HAVE_LCD_COLOR |
442 | read_color_theme_file(); | 438 | read_color_theme_file(); |
@@ -459,7 +455,7 @@ static void rm_whitespaces(char* str) | |||
459 | *s = '\0'; | 455 | *s = '\0'; |
460 | } | 456 | } |
461 | 457 | ||
462 | static void read_builtin_types(void) | 458 | static void read_builtin_types_init(void) |
463 | { | 459 | { |
464 | int tree_attr; | 460 | int tree_attr; |
465 | size_t count = ARRAY_SIZE(inbuilt_filetypes); | 461 | size_t count = ARRAY_SIZE(inbuilt_filetypes); |
@@ -487,7 +483,7 @@ static void read_builtin_types(void) | |||
487 | } | 483 | } |
488 | } | 484 | } |
489 | 485 | ||
490 | static void read_config(int fd) | 486 | static void read_config_init(int fd) |
491 | { | 487 | { |
492 | char line[64], *s, *e; | 488 | char line[64], *s, *e; |
493 | char *extension, *plugin; | 489 | char *extension, *plugin; |
diff --git a/apps/filetypes.h b/apps/filetypes.h index 9013f81b02..5aae772a9c 100644 --- a/apps/filetypes.h +++ b/apps/filetypes.h | |||
@@ -55,12 +55,12 @@ struct filetype { | |||
55 | int tree_attr; | 55 | int tree_attr; |
56 | }; | 56 | }; |
57 | 57 | ||
58 | void tree_get_filetypes(const struct filetype**, int*) INIT_ATTR; | 58 | long tree_get_filetype_voiceclip(int attr); |
59 | long tree_get_filetype_voiceclip(int attr) INIT_ATTR; | ||
60 | 59 | ||
61 | /* init the filetypes structs. | 60 | /* init the filetypes structs. |
62 | uses audio buffer for storage, so call early in init... */ | 61 | uses audio buffer for storage, so call early in init... */ |
63 | void filetype_init(void) INIT_ATTR; | 62 | void filetype_init(void) INIT_ATTR; |
63 | |||
64 | void read_viewer_theme_file(void); | 64 | void read_viewer_theme_file(void); |
65 | #ifdef HAVE_LCD_COLOR | 65 | #ifdef HAVE_LCD_COLOR |
66 | void read_color_theme_file(void); | 66 | void read_color_theme_file(void); |
diff --git a/apps/tree.c b/apps/tree.c index 3684e395a1..4df2c4e327 100644 --- a/apps/tree.c +++ b/apps/tree.c | |||
@@ -77,9 +77,6 @@ | |||
77 | 77 | ||
78 | #include "root_menu.h" | 78 | #include "root_menu.h" |
79 | 79 | ||
80 | static const struct filetype *filetypes; | ||
81 | static int filetypes_count; | ||
82 | |||
83 | static struct gui_synclist tree_lists; | 80 | static struct gui_synclist tree_lists; |
84 | 81 | ||
85 | /* I put it here because other files doesn't use it yet, | 82 | /* I put it here because other files doesn't use it yet, |
@@ -1090,7 +1087,6 @@ void tree_mem_init(void) | |||
1090 | cache->entries_handle = core_alloc_ex("tree entries", | 1087 | cache->entries_handle = core_alloc_ex("tree entries", |
1091 | cache->max_entries*(sizeof(struct entry)), | 1088 | cache->max_entries*(sizeof(struct entry)), |
1092 | &ops); | 1089 | &ops); |
1093 | tree_get_filetypes(&filetypes, &filetypes_count); | ||
1094 | } | 1090 | } |
1095 | 1091 | ||
1096 | bool bookmark_play(char *resume_file, int index, unsigned long elapsed, | 1092 | bool bookmark_play(char *resume_file, int index, unsigned long elapsed, |