diff options
-rw-r--r-- | apps/plugin.c | 22 | ||||
-rw-r--r-- | apps/plugin.h | 2 |
2 files changed, 24 insertions, 0 deletions
diff --git a/apps/plugin.c b/apps/plugin.c index 670770dfc6..e0766e47bf 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -809,6 +809,7 @@ static const struct plugin_api rockbox_api = { | |||
809 | onplay_show_playlist_menu, | 809 | onplay_show_playlist_menu, |
810 | queue_remove_from_head, | 810 | queue_remove_from_head, |
811 | core_set_keyremap, | 811 | core_set_keyremap, |
812 | plugin_reserve_buffer, | ||
812 | }; | 813 | }; |
813 | 814 | ||
814 | static int plugin_buffer_handle; | 815 | static int plugin_buffer_handle; |
@@ -963,6 +964,27 @@ int plugin_load(const char* plugin, const void* parameter) | |||
963 | return rc; | 964 | return rc; |
964 | } | 965 | } |
965 | 966 | ||
967 | /* For Terminate Stay Resident plugins | ||
968 | * Locks buffer_size bytes of the plugin buffer | ||
969 | * freed on plugin exit; call plugin_get_buffer first then reserve all | ||
970 | * or a portion with plugin_reserve_buffer() | ||
971 | * Returns size of buffer remaining */ | ||
972 | size_t plugin_reserve_buffer(size_t buffer_size) | ||
973 | { | ||
974 | size_t locked_size = 0; | ||
975 | |||
976 | if (current_plugin_handle) | ||
977 | { | ||
978 | locked_size = ALIGN_UP(plugin_size + buffer_size, 0x8); | ||
979 | if (locked_size > PLUGIN_BUFFER_SIZE) | ||
980 | locked_size = PLUGIN_BUFFER_SIZE; | ||
981 | |||
982 | plugin_size = locked_size; | ||
983 | } | ||
984 | |||
985 | return (PLUGIN_BUFFER_SIZE - locked_size); | ||
986 | } | ||
987 | |||
966 | /* Returns a pointer to the portion of the plugin buffer that is not already | 988 | /* Returns a pointer to the portion of the plugin buffer that is not already |
967 | being used. If no plugin is loaded, returns the entire plugin buffer */ | 989 | being used. If no plugin is loaded, returns the entire plugin buffer */ |
968 | void* plugin_get_buffer(size_t *buffer_size) | 990 | void* plugin_get_buffer(size_t *buffer_size) |
diff --git a/apps/plugin.h b/apps/plugin.h index de1077c9b4..2e0ace2e48 100644 --- a/apps/plugin.h +++ b/apps/plugin.h | |||
@@ -49,6 +49,7 @@ | |||
49 | 49 | ||
50 | char* strncpy(char *, const char *, size_t); | 50 | char* strncpy(char *, const char *, size_t); |
51 | void* plugin_get_buffer(size_t *buffer_size); | 51 | void* plugin_get_buffer(size_t *buffer_size); |
52 | size_t plugin_reserve_buffer(size_t buffer_size); | ||
52 | int plugin_open(const char *plugin, const char *parameter); | 53 | int plugin_open(const char *plugin, const char *parameter); |
53 | 54 | ||
54 | #ifndef __PCTOOL__ | 55 | #ifndef __PCTOOL__ |
@@ -935,6 +936,7 @@ struct plugin_api { | |||
935 | void (*onplay_show_playlist_menu)(const char* path, void (*playlist_insert_cb)); | 936 | void (*onplay_show_playlist_menu)(const char* path, void (*playlist_insert_cb)); |
936 | void (*queue_remove_from_head)(struct event_queue *q, long id); | 937 | void (*queue_remove_from_head)(struct event_queue *q, long id); |
937 | int (*core_set_keyremap)(struct button_mapping* core_keymap, int count); | 938 | int (*core_set_keyremap)(struct button_mapping* core_keymap, int count); |
939 | size_t (*plugin_reserve_buffer)(size_t buffer_size); | ||
938 | }; | 940 | }; |
939 | 941 | ||
940 | /* plugin header */ | 942 | /* plugin header */ |