diff options
author | Solomon Peachy <pizza@shaftnet.org> | 2019-02-03 20:12:50 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2019-07-20 08:48:35 +0200 |
commit | 55eb1c54ebe33faa8b1eb8c527d5644961ca78dc (patch) | |
tree | 81b5a4f89cfc867bc73901c7cccffc89baf3c3ff /apps/plugin.h | |
parent | 9c17734394177791d1101e31aed7537c81e610b6 (diff) | |
download | rockbox-55eb1c54ebe33faa8b1eb8c527d5644961ca78dc.tar.gz rockbox-55eb1c54ebe33faa8b1eb8c527d5644961ca78dc.zip |
FS#7704 - Talk support for plugins
Original patch by Mario Lang
Heavily updated by Igor Poretsky
Further updated by myself
This patch breaks binary API compatibility by placing the new
functions where they make the most logical sense. IMO this is
the better approach to take given the scope of the changes needed
for talk support.
Since binary API is changing, the patch also moves some other
functions around to more logical locations.
As well as voice support in plugins, this patch voice-enables several
simple plugins. There will be follow-up patches for many plugins that
build on this one.
Change-Id: I18070c06e77e8a3c016c2eb6b6c5dbe6633b9b54
Diffstat (limited to 'apps/plugin.h')
-rw-r--r-- | apps/plugin.h | 71 |
1 files changed, 53 insertions, 18 deletions
diff --git a/apps/plugin.h b/apps/plugin.h index 868c2a68e3..50f71914e9 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -71,6 +71,9 @@ void* plugin_get_buffer(size_t *buffer_size); | |||
71 | #include "mp3_playback.h" | 71 | #include "mp3_playback.h" |
72 | #include "root_menu.h" | 72 | #include "root_menu.h" |
73 | #include "talk.h" | 73 | #include "talk.h" |
74 | #ifdef PLUGIN | ||
75 | #include "lang_enum.h" | ||
76 | #endif | ||
74 | #ifdef RB_PROFILE | 77 | #ifdef RB_PROFILE |
75 | #include "profile.h" | 78 | #include "profile.h" |
76 | #endif | 79 | #endif |
@@ -160,12 +163,12 @@ void* plugin_get_buffer(size_t *buffer_size); | |||
160 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ | 163 | #define PLUGIN_MAGIC 0x526F634B /* RocK */ |
161 | 164 | ||
162 | /* increase this every time the api struct changes */ | 165 | /* increase this every time the api struct changes */ |
163 | #define PLUGIN_API_VERSION 235 | 166 | #define PLUGIN_API_VERSION 236 |
164 | 167 | ||
165 | /* update this to latest version if a change to the api struct breaks | 168 | /* update this to latest version if a change to the api struct breaks |
166 | backwards compatibility (and please take the opportunity to sort in any | 169 | backwards compatibility (and please take the opportunity to sort in any |
167 | new function which are "waiting" at the end of the function table) */ | 170 | new function which are "waiting" at the end of the function table) */ |
168 | #define PLUGIN_MIN_API_VERSION 235 | 171 | #define PLUGIN_MIN_API_VERSION 236 |
169 | 172 | ||
170 | /* plugin return codes */ | 173 | /* plugin return codes */ |
171 | /* internal returns start at 0x100 to make exit(1..255) work */ | 174 | /* internal returns start at 0x100 to make exit(1..255) work */ |
@@ -186,9 +189,13 @@ enum plugin_status { | |||
186 | version | 189 | version |
187 | */ | 190 | */ |
188 | struct plugin_api { | 191 | struct plugin_api { |
192 | /* let's put these at the top */ | ||
193 | const char *rbversion; | ||
194 | struct user_settings* global_settings; | ||
195 | struct system_status *global_status; | ||
196 | unsigned char **language_strings; | ||
189 | 197 | ||
190 | /* lcd */ | 198 | /* lcd */ |
191 | |||
192 | #ifdef HAVE_LCD_CONTRAST | 199 | #ifdef HAVE_LCD_CONTRAST |
193 | void (*lcd_set_contrast)(int x); | 200 | void (*lcd_set_contrast)(int x); |
194 | #endif | 201 | #endif |
@@ -284,6 +291,7 @@ struct plugin_api { | |||
284 | unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation ); | 291 | unsigned short *(*bidi_l2v)( const unsigned char *str, int orientation ); |
285 | #ifdef HAVE_LCD_BITMAP | 292 | #ifdef HAVE_LCD_BITMAP |
286 | bool (*is_diacritic)(const unsigned short char_code, bool *is_rtl); | 293 | bool (*is_diacritic)(const unsigned short char_code, bool *is_rtl); |
294 | const char* (*get_codepage_name)(int cp); | ||
287 | #endif | 295 | #endif |
288 | const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code ); | 296 | const unsigned char *(*font_get_bits)( struct font *pf, unsigned short char_code ); |
289 | int (*font_load)(const char *path); | 297 | int (*font_load)(const char *path); |
@@ -299,8 +307,6 @@ struct plugin_api { | |||
299 | int min_shown, int max_shown, | 307 | int min_shown, int max_shown, |
300 | unsigned flags); | 308 | unsigned flags); |
301 | #endif /* HAVE_LCD_BITMAP */ | 309 | #endif /* HAVE_LCD_BITMAP */ |
302 | const char* (*get_codepage_name)(int cp); | ||
303 | |||
304 | /* backlight */ | 310 | /* backlight */ |
305 | /* The backlight_* functions must be present in the API regardless whether | 311 | /* The backlight_* functions must be present in the API regardless whether |
306 | * HAVE_BACKLIGHT is defined or not. The reason is that the stock Ondio has | 312 | * HAVE_BACKLIGHT is defined or not. The reason is that the stock Ondio has |
@@ -370,7 +376,7 @@ struct plugin_api { | |||
370 | int width, int height); | 376 | int width, int height); |
371 | #endif | 377 | #endif |
372 | void (*viewport_set_defaults)(struct viewport *vp, | 378 | void (*viewport_set_defaults)(struct viewport *vp, |
373 | const enum screen_type screen); | 379 | const enum screen_type screen); |
374 | #ifdef HAVE_LCD_BITMAP | 380 | #ifdef HAVE_LCD_BITMAP |
375 | void (*viewportmanager_theme_enable)(enum screen_type screen, bool enable, | 381 | void (*viewportmanager_theme_enable)(enum screen_type screen, bool enable, |
376 | struct viewport *viewport); | 382 | struct viewport *viewport); |
@@ -384,11 +390,13 @@ struct plugin_api { | |||
384 | bool scroll_all,int selected_size, | 390 | bool scroll_all,int selected_size, |
385 | struct viewport parent[NB_SCREENS]); | 391 | struct viewport parent[NB_SCREENS]); |
386 | void (*gui_synclist_set_nb_items)(struct gui_synclist * lists, int nb_items); | 392 | void (*gui_synclist_set_nb_items)(struct gui_synclist * lists, int nb_items); |
393 | void (*gui_synclist_set_voice_callback)(struct gui_synclist * lists, list_speak_item voice_callback); | ||
387 | void (*gui_synclist_set_icon_callback)(struct gui_synclist * lists, | 394 | void (*gui_synclist_set_icon_callback)(struct gui_synclist * lists, |
388 | list_get_icon icon_callback); | 395 | list_get_icon icon_callback); |
389 | int (*gui_synclist_get_nb_items)(struct gui_synclist * lists); | 396 | int (*gui_synclist_get_nb_items)(struct gui_synclist * lists); |
390 | int (*gui_synclist_get_sel_pos)(struct gui_synclist * lists); | 397 | int (*gui_synclist_get_sel_pos)(struct gui_synclist * lists); |
391 | void (*gui_synclist_draw)(struct gui_synclist * lists); | 398 | void (*gui_synclist_draw)(struct gui_synclist * lists); |
399 | void (*gui_synclist_speak_item)(struct gui_synclist * lists); | ||
392 | void (*gui_synclist_select_item)(struct gui_synclist * lists, | 400 | void (*gui_synclist_select_item)(struct gui_synclist * lists, |
393 | int item_number); | 401 | int item_number); |
394 | void (*gui_synclist_add_item)(struct gui_synclist * lists); | 402 | void (*gui_synclist_add_item)(struct gui_synclist * lists); |
@@ -463,8 +471,6 @@ struct plugin_api { | |||
463 | 471 | ||
464 | int (*filetype_get_attr)(const char* file); | 472 | int (*filetype_get_attr)(const char* file); |
465 | 473 | ||
466 | |||
467 | |||
468 | /* dir */ | 474 | /* dir */ |
469 | DIR * (*opendir)(const char *dirname); | 475 | DIR * (*opendir)(const char *dirname); |
470 | int (*closedir)(DIR *dirp); | 476 | int (*closedir)(DIR *dirp); |
@@ -481,6 +487,24 @@ struct plugin_api { | |||
481 | const char *root, const char *selected); | 487 | const char *root, const char *selected); |
482 | int (*rockbox_browse)(struct browse_context *browse); | 488 | int (*rockbox_browse)(struct browse_context *browse); |
483 | 489 | ||
490 | /* talking */ | ||
491 | int (*talk_id)(int32_t id, bool enqueue); | ||
492 | int (*talk_file)(const char *root, const char *dir, const char *file, | ||
493 | const char *ext, const long *prefix_ids, bool enqueue); | ||
494 | int (*talk_file_or_spell)(const char *dirname, const char* filename, | ||
495 | const long *prefix_ids, bool enqueue); | ||
496 | int (*talk_dir_or_spell)(const char* filename, | ||
497 | const long *prefix_ids, bool enqueue); | ||
498 | int (*talk_number)(long n, bool enqueue); | ||
499 | int (*talk_value)(long n, int unit, bool enqueue); | ||
500 | int (*talk_spell)(const char* spell, bool enqueue); | ||
501 | void (*talk_time)(const struct tm *tm, bool enqueue); | ||
502 | void (*talk_date)(const struct tm *tm, bool enqueue); | ||
503 | void (*talk_disable)(bool disable); | ||
504 | void (*talk_shutup)(void); | ||
505 | void (*talk_force_shutup)(void); | ||
506 | void (*talk_force_enqueue_next)(void); | ||
507 | |||
484 | /* kernel/ system */ | 508 | /* kernel/ system */ |
485 | #if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE | 509 | #if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE |
486 | void (*__div0)(void); | 510 | void (*__div0)(void); |
@@ -716,6 +740,7 @@ struct plugin_api { | |||
716 | chan_buffer_hook_fn_type fn); | 740 | chan_buffer_hook_fn_type fn); |
717 | void (*mixer_set_frequency)(unsigned int samplerate); | 741 | void (*mixer_set_frequency)(unsigned int samplerate); |
718 | unsigned int (*mixer_get_frequency)(void); | 742 | unsigned int (*mixer_get_frequency)(void); |
743 | void (*pcmbuf_fade)(bool fade, bool in); | ||
719 | void (*system_sound_play)(enum system_sound sound); | 744 | void (*system_sound_play)(enum system_sound sound); |
720 | void (*keyclick_click)(bool rawbutton, int action); | 745 | void (*keyclick_click)(bool rawbutton, int action); |
721 | #endif /* CONFIG_CODEC == SWCODC */ | 746 | #endif /* CONFIG_CODEC == SWCODC */ |
@@ -773,8 +798,12 @@ struct plugin_api { | |||
773 | #endif | 798 | #endif |
774 | 799 | ||
775 | /* menu */ | 800 | /* menu */ |
801 | struct menu_table *(*root_menu_get_options)(int *nb_options); | ||
776 | int (*do_menu)(const struct menu_item_ex *menu, int *start_selected, | 802 | int (*do_menu)(const struct menu_item_ex *menu, int *start_selected, |
777 | struct viewport parent[NB_SCREENS], bool hide_theme); | 803 | struct viewport parent[NB_SCREENS], bool hide_theme); |
804 | void (*root_menu_set_default)(void* setting, void* defaultval); | ||
805 | char* (*root_menu_write_to_cfg)(void* setting, char*buf, int buf_len); | ||
806 | void (*root_menu_load_from_cfg)(void* setting, char *value); | ||
778 | 807 | ||
779 | /* scroll bar */ | 808 | /* scroll bar */ |
780 | struct gui_syncstatusbar *statusbars; | 809 | struct gui_syncstatusbar *statusbars; |
@@ -783,6 +812,7 @@ struct plugin_api { | |||
783 | /* options */ | 812 | /* options */ |
784 | const struct settings_list* (*get_settings_list)(int*count); | 813 | const struct settings_list* (*get_settings_list)(int*count); |
785 | const struct settings_list* (*find_setting)(const void* variable, int *id); | 814 | const struct settings_list* (*find_setting)(const void* variable, int *id); |
815 | int (*settings_save)(void); | ||
786 | bool (*option_screen)(const struct settings_list *setting, | 816 | bool (*option_screen)(const struct settings_list *setting, |
787 | struct viewport parent[NB_SCREENS], | 817 | struct viewport parent[NB_SCREENS], |
788 | bool use_temp_var, unsigned char* option_title); | 818 | bool use_temp_var, unsigned char* option_title); |
@@ -797,6 +827,11 @@ struct plugin_api { | |||
797 | const int* variable, void (*function)(int), int step, | 827 | const int* variable, void (*function)(int), int step, |
798 | int min, int max, | 828 | int min, int max, |
799 | const char* (*formatter)(char*, size_t, int, const char*) ); | 829 | const char* (*formatter)(char*, size_t, int, const char*) ); |
830 | bool (*set_int_ex)(const unsigned char* string, const char* unit, int voice_unit, | ||
831 | const int* variable, void (*function)(int), int step, | ||
832 | int min, int max, | ||
833 | const char* (*formatter)(char*, size_t, int, const char*) , | ||
834 | int32_t (*get_talk_id)(int, int)); | ||
800 | bool (*set_bool)(const char* string, const bool* variable ); | 835 | bool (*set_bool)(const char* string, const bool* variable ); |
801 | 836 | ||
802 | #ifdef HAVE_LCD_COLOR | 837 | #ifdef HAVE_LCD_COLOR |
@@ -846,15 +881,15 @@ struct plugin_api { | |||
846 | void (*plugin_release_audio_buffer)(void); | 881 | void (*plugin_release_audio_buffer)(void); |
847 | void (*plugin_tsr)(bool (*exit_callback)(bool reenter)); | 882 | void (*plugin_tsr)(bool (*exit_callback)(bool reenter)); |
848 | char* (*plugin_get_current_filename)(void); | 883 | char* (*plugin_get_current_filename)(void); |
884 | #ifdef PLUGIN_USE_IRAM | ||
885 | void (*audio_hard_stop)(void); | ||
886 | #endif | ||
849 | #if defined(DEBUG) || defined(SIMULATOR) | 887 | #if defined(DEBUG) || defined(SIMULATOR) |
850 | void (*debugf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2); | 888 | void (*debugf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2); |
851 | #endif | 889 | #endif |
852 | #ifdef ROCKBOX_HAS_LOGF | 890 | #ifdef ROCKBOX_HAS_LOGF |
853 | void (*logf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2); | 891 | void (*logf)(const char *fmt, ...) ATTRIBUTE_PRINTF(1, 2); |
854 | #endif | 892 | #endif |
855 | struct user_settings* global_settings; | ||
856 | struct system_status *global_status; | ||
857 | void (*talk_disable)(bool disable); | ||
858 | #if CONFIG_CODEC == SWCODEC | 893 | #if CONFIG_CODEC == SWCODEC |
859 | void (*codec_thread_do_callback)(void (*fn)(void), | 894 | void (*codec_thread_do_callback)(void (*fn)(void), |
860 | unsigned int *audio_thread_id); | 895 | unsigned int *audio_thread_id); |
@@ -950,13 +985,6 @@ struct plugin_api { | |||
950 | void (*semaphore_release)(struct semaphore *s); | 985 | void (*semaphore_release)(struct semaphore *s); |
951 | #endif | 986 | #endif |
952 | 987 | ||
953 | const char *rbversion; | ||
954 | struct menu_table *(*root_menu_get_options)(int *nb_options); | ||
955 | void (*root_menu_set_default)(void* setting, void* defaultval); | ||
956 | char* (*root_menu_write_to_cfg)(void* setting, char*buf, int buf_len); | ||
957 | void (*root_menu_load_from_cfg)(void* setting, char *value); | ||
958 | int (*settings_save)(void); | ||
959 | |||
960 | /* new stuff at the end, sort into place next time | 988 | /* new stuff at the end, sort into place next time |
961 | the API gets incompatible */ | 989 | the API gets incompatible */ |
962 | }; | 990 | }; |
@@ -988,6 +1016,13 @@ extern unsigned char plugin_end_addr[]; | |||
988 | #endif /* CONFIG_PLATFORM */ | 1016 | #endif /* CONFIG_PLATFORM */ |
989 | #endif /* PLUGIN */ | 1017 | #endif /* PLUGIN */ |
990 | 1018 | ||
1019 | /* | ||
1020 | * The str() macro/functions is how to access strings that might be | ||
1021 | * translated. Use it like str(MACRO) and expect a string to be | ||
1022 | * returned! | ||
1023 | */ | ||
1024 | #define str(x) language_strings[x] | ||
1025 | |||
991 | int plugin_load(const char* plugin, const void* parameter); | 1026 | int plugin_load(const char* plugin, const void* parameter); |
992 | 1027 | ||
993 | /* defined by the plugin */ | 1028 | /* defined by the plugin */ |