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.c | |
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.c')
-rw-r--r-- | apps/plugin.c | 65 |
1 files changed, 44 insertions, 21 deletions
diff --git a/apps/plugin.c b/apps/plugin.c index 97ff7c8c43..7d4199a607 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -176,6 +176,10 @@ static void plugin_check_open_close__exit(void) | |||
176 | #endif /* HAVE_PLUGIN_CHECK_OPEN_CLOSE */ | 176 | #endif /* HAVE_PLUGIN_CHECK_OPEN_CLOSE */ |
177 | 177 | ||
178 | static const struct plugin_api rockbox_api = { | 178 | static const struct plugin_api rockbox_api = { |
179 | rbversion, | ||
180 | &global_settings, | ||
181 | &global_status, | ||
182 | language_strings, | ||
179 | 183 | ||
180 | /* lcd */ | 184 | /* lcd */ |
181 | #ifdef HAVE_LCD_CONTRAST | 185 | #ifdef HAVE_LCD_CONTRAST |
@@ -258,6 +262,7 @@ static const struct plugin_api rockbox_api = { | |||
258 | bidi_l2v, | 262 | bidi_l2v, |
259 | #ifdef HAVE_LCD_BITMAP | 263 | #ifdef HAVE_LCD_BITMAP |
260 | is_diacritic, | 264 | is_diacritic, |
265 | get_codepage_name, | ||
261 | #endif | 266 | #endif |
262 | font_get_bits, | 267 | font_get_bits, |
263 | font_load, | 268 | font_load, |
@@ -268,7 +273,6 @@ static const struct plugin_api rockbox_api = { | |||
268 | screen_clear_area, | 273 | screen_clear_area, |
269 | gui_scrollbar_draw, | 274 | gui_scrollbar_draw, |
270 | #endif /* HAVE_LCD_BITMAP */ | 275 | #endif /* HAVE_LCD_BITMAP */ |
271 | get_codepage_name, | ||
272 | 276 | ||
273 | backlight_on, | 277 | backlight_on, |
274 | backlight_off, | 278 | backlight_off, |
@@ -334,14 +338,16 @@ static const struct plugin_api rockbox_api = { | |||
334 | viewportmanager_theme_undo, | 338 | viewportmanager_theme_undo, |
335 | viewport_set_fullscreen, | 339 | viewport_set_fullscreen, |
336 | #endif | 340 | #endif |
337 | 341 | ||
338 | /* list */ | 342 | /* list */ |
339 | gui_synclist_init, | 343 | gui_synclist_init, |
340 | gui_synclist_set_nb_items, | 344 | gui_synclist_set_nb_items, |
345 | gui_synclist_set_voice_callback, | ||
341 | gui_synclist_set_icon_callback, | 346 | gui_synclist_set_icon_callback, |
342 | gui_synclist_get_nb_items, | 347 | gui_synclist_get_nb_items, |
343 | gui_synclist_get_sel_pos, | 348 | gui_synclist_get_sel_pos, |
344 | gui_synclist_draw, | 349 | gui_synclist_draw, |
350 | gui_synclist_speak_item, | ||
345 | gui_synclist_select_item, | 351 | gui_synclist_select_item, |
346 | gui_synclist_add_item, | 352 | gui_synclist_add_item, |
347 | gui_synclist_del_item, | 353 | gui_synclist_del_item, |
@@ -369,7 +375,7 @@ static const struct plugin_api rockbox_api = { | |||
369 | touchscreen_set_mode, | 375 | touchscreen_set_mode, |
370 | touchscreen_get_mode, | 376 | touchscreen_get_mode, |
371 | #endif | 377 | #endif |
372 | 378 | ||
373 | #ifdef HAVE_BUTTON_LIGHT | 379 | #ifdef HAVE_BUTTON_LIGHT |
374 | buttonlight_set_timeout, | 380 | buttonlight_set_timeout, |
375 | buttonlight_off, | 381 | buttonlight_off, |
@@ -421,6 +427,21 @@ static const struct plugin_api rockbox_api = { | |||
421 | browse_context_init, | 427 | browse_context_init, |
422 | rockbox_browse, | 428 | rockbox_browse, |
423 | 429 | ||
430 | /* talking */ | ||
431 | talk_id, | ||
432 | talk_file, | ||
433 | talk_file_or_spell, | ||
434 | talk_dir_or_spell, | ||
435 | talk_number, | ||
436 | talk_value, | ||
437 | talk_spell, | ||
438 | talk_time, | ||
439 | talk_date, | ||
440 | talk_disable, | ||
441 | talk_shutup, | ||
442 | talk_force_shutup, | ||
443 | talk_force_enqueue_next, | ||
444 | |||
424 | /* kernel/ system */ | 445 | /* kernel/ system */ |
425 | #if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE | 446 | #if defined(CPU_ARM) && CONFIG_PLATFORM & PLATFORM_NATIVE |
426 | __div0, | 447 | __div0, |
@@ -541,7 +562,7 @@ static const struct plugin_api rockbox_api = { | |||
541 | utf8encode, | 562 | utf8encode, |
542 | utf8length, | 563 | utf8length, |
543 | utf8seek, | 564 | utf8seek, |
544 | 565 | ||
545 | /* the buflib memory management library */ | 566 | /* the buflib memory management library */ |
546 | buflib_init, | 567 | buflib_init, |
547 | buflib_available, | 568 | buflib_available, |
@@ -625,6 +646,7 @@ static const struct plugin_api rockbox_api = { | |||
625 | mixer_set_frequency, | 646 | mixer_set_frequency, |
626 | mixer_get_frequency, | 647 | mixer_get_frequency, |
627 | 648 | ||
649 | pcmbuf_fade, | ||
628 | system_sound_play, | 650 | system_sound_play, |
629 | keyclick_click, | 651 | keyclick_click, |
630 | #endif /* CONFIG_CODEC == SWCODEC */ | 652 | #endif /* CONFIG_CODEC == SWCODEC */ |
@@ -676,7 +698,12 @@ static const struct plugin_api rockbox_api = { | |||
676 | #endif /* !SIMULATOR && CONFIG_CODEC != SWCODEC */ | 698 | #endif /* !SIMULATOR && CONFIG_CODEC != SWCODEC */ |
677 | 699 | ||
678 | /* menu */ | 700 | /* menu */ |
701 | root_menu_get_options, | ||
679 | do_menu, | 702 | do_menu, |
703 | root_menu_set_default, | ||
704 | root_menu_write_to_cfg, | ||
705 | root_menu_load_from_cfg, | ||
706 | |||
680 | /* statusbars */ | 707 | /* statusbars */ |
681 | &statusbars, | 708 | &statusbars, |
682 | gui_syncstatusbar_draw, | 709 | gui_syncstatusbar_draw, |
@@ -684,10 +711,12 @@ static const struct plugin_api rockbox_api = { | |||
684 | /* options */ | 711 | /* options */ |
685 | get_settings_list, | 712 | get_settings_list, |
686 | find_setting, | 713 | find_setting, |
714 | settings_save, | ||
687 | option_screen, | 715 | option_screen, |
688 | set_option, | 716 | set_option, |
689 | set_bool_options, | 717 | set_bool_options, |
690 | set_int, | 718 | set_int, |
719 | set_int_ex, | ||
691 | set_bool, | 720 | set_bool, |
692 | #ifdef HAVE_LCD_COLOR | 721 | #ifdef HAVE_LCD_COLOR |
693 | set_color, | 722 | set_color, |
@@ -731,17 +760,17 @@ static const struct plugin_api rockbox_api = { | |||
731 | plugin_get_buffer, | 760 | plugin_get_buffer, |
732 | plugin_get_audio_buffer, /* defined in plugin.c */ | 761 | plugin_get_audio_buffer, /* defined in plugin.c */ |
733 | plugin_release_audio_buffer, /* defined in plugin.c */ | 762 | plugin_release_audio_buffer, /* defined in plugin.c */ |
734 | plugin_tsr, /* defined in plugin.c */ | 763 | plugin_tsr, /* defined in plugin.c */ |
735 | plugin_get_current_filename, | 764 | plugin_get_current_filename, |
765 | #ifdef PLUGIN_USE_IRAM | ||
766 | audio_hard_stop, | ||
767 | #endif | ||
736 | #if defined(DEBUG) || defined(SIMULATOR) | 768 | #if defined(DEBUG) || defined(SIMULATOR) |
737 | debugf, | 769 | debugf, |
738 | #endif | 770 | #endif |
739 | #ifdef ROCKBOX_HAS_LOGF | 771 | #ifdef ROCKBOX_HAS_LOGF |
740 | _logf, | 772 | _logf, |
741 | #endif | 773 | #endif |
742 | &global_settings, | ||
743 | &global_status, | ||
744 | talk_disable, | ||
745 | #if CONFIG_CODEC == SWCODEC | 774 | #if CONFIG_CODEC == SWCODEC |
746 | codec_thread_do_callback, | 775 | codec_thread_do_callback, |
747 | codec_load_file, | 776 | codec_load_file, |
@@ -813,13 +842,6 @@ static const struct plugin_api rockbox_api = { | |||
813 | semaphore_release, | 842 | semaphore_release, |
814 | #endif | 843 | #endif |
815 | 844 | ||
816 | rbversion, | ||
817 | root_menu_get_options, | ||
818 | root_menu_set_default, | ||
819 | root_menu_write_to_cfg, | ||
820 | root_menu_load_from_cfg, | ||
821 | settings_save, | ||
822 | |||
823 | /* new stuff at the end, sort into place next time | 845 | /* new stuff at the end, sort into place next time |
824 | the API gets incompatible */ | 846 | the API gets incompatible */ |
825 | }; | 847 | }; |
@@ -857,7 +879,7 @@ int plugin_load(const char* plugin, const void* parameter) | |||
857 | p_hdr = lc_get_header(current_plugin_handle); | 879 | p_hdr = lc_get_header(current_plugin_handle); |
858 | 880 | ||
859 | hdr = p_hdr ? &p_hdr->lc_hdr : NULL; | 881 | hdr = p_hdr ? &p_hdr->lc_hdr : NULL; |
860 | 882 | ||
861 | 883 | ||
862 | if (hdr == NULL | 884 | if (hdr == NULL |
863 | || hdr->magic != PLUGIN_MAGIC | 885 | || hdr->magic != PLUGIN_MAGIC |
@@ -869,14 +891,14 @@ int plugin_load(const char* plugin, const void* parameter) | |||
869 | ) | 891 | ) |
870 | { | 892 | { |
871 | lc_close(current_plugin_handle); | 893 | lc_close(current_plugin_handle); |
872 | splash(HZ*2, str(LANG_PLUGIN_WRONG_MODEL)); | 894 | splash(HZ*2, ID2P(LANG_PLUGIN_WRONG_MODEL)); |
873 | return -1; | 895 | return -1; |
874 | } | 896 | } |
875 | if (hdr->api_version > PLUGIN_API_VERSION | 897 | if (hdr->api_version > PLUGIN_API_VERSION |
876 | || hdr->api_version < PLUGIN_MIN_API_VERSION) | 898 | || hdr->api_version < PLUGIN_MIN_API_VERSION) |
877 | { | 899 | { |
878 | lc_close(current_plugin_handle); | 900 | lc_close(current_plugin_handle); |
879 | splash(HZ*2, str(LANG_PLUGIN_WRONG_VERSION)); | 901 | splash(HZ*2, ID2P(LANG_PLUGIN_WRONG_VERSION)); |
880 | return -1; | 902 | return -1; |
881 | } | 903 | } |
882 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) | 904 | #if (CONFIG_PLATFORM & PLATFORM_NATIVE) |
@@ -901,18 +923,19 @@ int plugin_load(const char* plugin, const void* parameter) | |||
901 | 923 | ||
902 | FOR_NB_SCREENS(i) | 924 | FOR_NB_SCREENS(i) |
903 | viewportmanager_theme_enable(i, false, NULL); | 925 | viewportmanager_theme_enable(i, false, NULL); |
904 | 926 | ||
905 | #ifdef HAVE_TOUCHSCREEN | 927 | #ifdef HAVE_TOUCHSCREEN |
906 | touchscreen_set_mode(TOUCHSCREEN_BUTTON); | 928 | touchscreen_set_mode(TOUCHSCREEN_BUTTON); |
907 | #endif | 929 | #endif |
908 | 930 | ||
909 | /* allow voice to back off if the plugin needs lots of memory */ | 931 | /* allow voice to back off if the plugin needs lots of memory */ |
910 | talk_buffer_set_policy(TALK_BUFFER_LOOSE); | 932 | if (!global_settings.talk_menu) |
933 | talk_buffer_set_policy(TALK_BUFFER_LOOSE); | ||
911 | 934 | ||
912 | plugin_check_open_close__enter(); | 935 | plugin_check_open_close__enter(); |
913 | 936 | ||
914 | int rc = p_hdr->entry_point(parameter); | 937 | int rc = p_hdr->entry_point(parameter); |
915 | 938 | ||
916 | tree_unlock_cache(tree_get_context()); | 939 | tree_unlock_cache(tree_get_context()); |
917 | pop_current_activity(); | 940 | pop_current_activity(); |
918 | 941 | ||