diff options
Diffstat (limited to 'apps/plugin.c')
-rw-r--r-- | apps/plugin.c | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/apps/plugin.c b/apps/plugin.c index 3db4bb2d80..cd58209fb7 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -74,7 +74,7 @@ extern unsigned char pluginbuf[]; | |||
74 | 74 | ||
75 | /* for actual plugins only, not for codecs */ | 75 | /* for actual plugins only, not for codecs */ |
76 | static int plugin_size = 0; | 76 | static int plugin_size = 0; |
77 | static bool (*pfn_tsr_exit)(bool reenter) = NULL; /* TSR exit callback */ | 77 | static int (*pfn_tsr_exit)(bool reenter) = NULL; /* TSR exit callback */ |
78 | static char current_plugin[MAX_PATH]; | 78 | static char current_plugin[MAX_PATH]; |
79 | /* NULL if no plugin is loaded, otherwise the handle that lc_open() returned */ | 79 | /* NULL if no plugin is loaded, otherwise the handle that lc_open() returned */ |
80 | static void *current_plugin_handle; | 80 | static void *current_plugin_handle; |
@@ -83,7 +83,7 @@ char *plugin_get_current_filename(void); | |||
83 | 83 | ||
84 | static void* plugin_get_audio_buffer(size_t *buffer_size); | 84 | static void* plugin_get_audio_buffer(size_t *buffer_size); |
85 | static void plugin_release_audio_buffer(void); | 85 | static void plugin_release_audio_buffer(void); |
86 | static void plugin_tsr(bool (*exit_callback)(bool)); | 86 | static void plugin_tsr(int (*exit_callback)(bool)); |
87 | 87 | ||
88 | #ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE | 88 | #ifdef HAVE_PLUGIN_CHECK_OPEN_CLOSE |
89 | /* File handle leak prophylaxis */ | 89 | /* File handle leak prophylaxis */ |
@@ -183,6 +183,8 @@ static const struct plugin_api rockbox_api = { | |||
183 | /* lcd */ | 183 | /* lcd */ |
184 | splash, | 184 | splash, |
185 | splashf, | 185 | splashf, |
186 | splash_progress, | ||
187 | splash_progress_set_delay, | ||
186 | #ifdef HAVE_LCD_CONTRAST | 188 | #ifdef HAVE_LCD_CONTRAST |
187 | lcd_set_contrast, | 189 | lcd_set_contrast, |
188 | #endif | 190 | #endif |
@@ -436,6 +438,7 @@ static const struct plugin_api rockbox_api = { | |||
436 | set_current_file, | 438 | set_current_file, |
437 | set_dirfilter, | 439 | set_dirfilter, |
438 | onplay_show_playlist_menu, | 440 | onplay_show_playlist_menu, |
441 | onplay_show_playlist_cat_menu, | ||
439 | browse_id3, | 442 | browse_id3, |
440 | 443 | ||
441 | /* talking */ | 444 | /* talking */ |
@@ -587,6 +590,7 @@ static const struct plugin_api rockbox_api = { | |||
587 | buflib_get_data, | 590 | buflib_get_data, |
588 | 591 | ||
589 | /* sound */ | 592 | /* sound */ |
593 | adjust_volume, | ||
590 | sound_set, | 594 | sound_set, |
591 | sound_current, /*stub*/ | 595 | sound_current, /*stub*/ |
592 | sound_default, | 596 | sound_default, |
@@ -674,6 +678,7 @@ static const struct plugin_api rockbox_api = { | |||
674 | tagcache_fill_tags, | 678 | tagcache_fill_tags, |
675 | #endif | 679 | #endif |
676 | #endif | 680 | #endif |
681 | tagtree_subentries_do_action, | ||
677 | #endif /* HAVE_TAGCACHE */ | 682 | #endif /* HAVE_TAGCACHE */ |
678 | 683 | ||
679 | #ifdef HAVE_ALBUMART | 684 | #ifdef HAVE_ALBUMART |
@@ -685,6 +690,7 @@ static const struct plugin_api rockbox_api = { | |||
685 | playlist_amount, | 690 | playlist_amount, |
686 | playlist_resume, | 691 | playlist_resume, |
687 | playlist_resume_track, | 692 | playlist_resume_track, |
693 | playlist_set_modified, | ||
688 | playlist_start, | 694 | playlist_start, |
689 | playlist_add, | 695 | playlist_add, |
690 | playlist_sync, | 696 | playlist_sync, |
@@ -814,6 +820,7 @@ static const struct plugin_api rockbox_api = { | |||
814 | sys_reboot, | 820 | sys_reboot, |
815 | 821 | ||
816 | /* pathfuncs */ | 822 | /* pathfuncs */ |
823 | fix_path_part, | ||
817 | #ifdef HAVE_MULTIVOLUME | 824 | #ifdef HAVE_MULTIVOLUME |
818 | path_strip_volume, | 825 | path_strip_volume, |
819 | #endif | 826 | #endif |
@@ -821,15 +828,6 @@ static const struct plugin_api rockbox_api = { | |||
821 | /* new stuff at the end, sort into place next time | 828 | /* new stuff at the end, sort into place next time |
822 | the API gets incompatible */ | 829 | the API gets incompatible */ |
823 | 830 | ||
824 | splash_progress, | ||
825 | splash_progress_set_delay, | ||
826 | fix_path_part, | ||
827 | onplay_show_playlist_cat_menu, | ||
828 | #if defined(HAVE_TAGCACHE) | ||
829 | tagtree_subentries_do_action, | ||
830 | #endif | ||
831 | adjust_volume, | ||
832 | playlist_set_modified, | ||
833 | }; | 831 | }; |
834 | 832 | ||
835 | static int plugin_buffer_handle; | 833 | static int plugin_buffer_handle; |
@@ -839,17 +837,31 @@ int plugin_load(const char* plugin, const void* parameter) | |||
839 | { | 837 | { |
840 | struct plugin_header *p_hdr; | 838 | struct plugin_header *p_hdr; |
841 | struct lc_header *hdr; | 839 | struct lc_header *hdr; |
840 | const char * resume_plugin = NULL; | ||
841 | |||
842 | if (!plugin) | ||
843 | return PLUGIN_ERROR; | ||
842 | 844 | ||
843 | if (current_plugin_handle && pfn_tsr_exit) | 845 | if (current_plugin_handle && pfn_tsr_exit) |
844 | { /* if we have a resident old plugin and a callback */ | 846 | { /* if we have a resident old plugin and a callback */ |
845 | if (pfn_tsr_exit(!strcmp(current_plugin, plugin)) == false ) | 847 | bool reenter = (strcmp(current_plugin, plugin) == 0); |
848 | int exit_status = pfn_tsr_exit(reenter); | ||
849 | if (exit_status == PLUGIN_TSR_CONTINUE) | ||
846 | { | 850 | { |
847 | /* not allowing another plugin to load */ | 851 | /* not allowing another plugin to load */ |
848 | return PLUGIN_OK; | 852 | return PLUGIN_OK; |
849 | } | 853 | } |
850 | lc_close(current_plugin_handle); | 854 | else |
851 | current_plugin_handle = pfn_tsr_exit = NULL; | 855 | { |
852 | plugin_buffer_handle = core_free(plugin_buffer_handle); | 856 | lc_close(current_plugin_handle); |
857 | current_plugin_handle = pfn_tsr_exit = NULL; | ||
858 | plugin_buffer_handle = core_free(plugin_buffer_handle); | ||
859 | |||
860 | if (!reenter) | ||
861 | resume_plugin = strdupa(current_plugin); | ||
862 | else if (exit_status == PLUGIN_TSR_TERMINATE) | ||
863 | return PLUGIN_OK; /* don't even load the new plugin either */ | ||
864 | } | ||
853 | } | 865 | } |
854 | 866 | ||
855 | #ifdef HAVE_DISK_STORAGE | 867 | #ifdef HAVE_DISK_STORAGE |
@@ -857,7 +869,6 @@ int plugin_load(const char* plugin, const void* parameter) | |||
857 | splash(0, ID2P(LANG_WAIT)); | 869 | splash(0, ID2P(LANG_WAIT)); |
858 | #endif | 870 | #endif |
859 | strcpy(current_plugin, plugin); | 871 | strcpy(current_plugin, plugin); |
860 | |||
861 | current_plugin_handle = lc_open(plugin, pluginbuf, PLUGIN_BUFFER_SIZE); | 872 | current_plugin_handle = lc_open(plugin, pluginbuf, PLUGIN_BUFFER_SIZE); |
862 | if (current_plugin_handle == NULL) { | 873 | if (current_plugin_handle == NULL) { |
863 | splashf(HZ*2, str(LANG_PLUGIN_CANT_OPEN), plugin); | 874 | splashf(HZ*2, str(LANG_PLUGIN_CANT_OPEN), plugin); |
@@ -990,6 +1001,12 @@ int plugin_load(const char* plugin, const void* parameter) | |||
990 | if (rc == PLUGIN_ERROR) | 1001 | if (rc == PLUGIN_ERROR) |
991 | splash(HZ*2, str(LANG_PLUGIN_ERROR)); | 1002 | splash(HZ*2, str(LANG_PLUGIN_ERROR)); |
992 | 1003 | ||
1004 | if (resume_plugin && rc != PLUGIN_GOTO_PLUGIN && !pfn_tsr_exit) | ||
1005 | { | ||
1006 | /*plugin = resume_plugin;*/ | ||
1007 | /*parameter = rockbox_api.plugin_tsr;*/ | ||
1008 | return plugin_load(resume_plugin, rockbox_api.plugin_tsr); | ||
1009 | } | ||
993 | return rc; | 1010 | return rc; |
994 | } | 1011 | } |
995 | 1012 | ||
@@ -1067,7 +1084,7 @@ static void plugin_release_audio_buffer(void) | |||
1067 | /* The plugin wants to stay resident after leaving its main function, e.g. | 1084 | /* The plugin wants to stay resident after leaving its main function, e.g. |
1068 | runs from timer or own thread. The callback is registered to later | 1085 | runs from timer or own thread. The callback is registered to later |
1069 | instruct it to free its resources before a new plugin gets loaded. */ | 1086 | instruct it to free its resources before a new plugin gets loaded. */ |
1070 | static void plugin_tsr(bool (*exit_callback)(bool)) | 1087 | static void plugin_tsr(int (*exit_callback)(bool)) |
1071 | { | 1088 | { |
1072 | pfn_tsr_exit = exit_callback; /* remember the callback for later */ | 1089 | pfn_tsr_exit = exit_callback; /* remember the callback for later */ |
1073 | } | 1090 | } |