diff options
-rw-r--r-- | apps/plugin.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/apps/plugin.c b/apps/plugin.c index d14b6468e0..33a46a3d84 100644 --- a/apps/plugin.c +++ b/apps/plugin.c | |||
@@ -841,6 +841,7 @@ static const struct plugin_api rockbox_api = { | |||
841 | }; | 841 | }; |
842 | 842 | ||
843 | static int plugin_buffer_handle; | 843 | static int plugin_buffer_handle; |
844 | static size_t plugin_buffer_size; | ||
844 | 845 | ||
845 | int plugin_load(const char* plugin, const void* parameter) | 846 | int plugin_load(const char* plugin, const void* parameter) |
846 | { | 847 | { |
@@ -1018,15 +1019,26 @@ static void* plugin_get_audio_buffer(size_t *buffer_size) | |||
1018 | /* dummy ops with no callbacks, needed because by | 1019 | /* dummy ops with no callbacks, needed because by |
1019 | * default buflib buffers can be moved around which must be avoided */ | 1020 | * default buflib buffers can be moved around which must be avoided */ |
1020 | static struct buflib_callbacks dummy_ops; | 1021 | static struct buflib_callbacks dummy_ops; |
1021 | plugin_buffer_handle = core_alloc_maximum("plugin audio buf", buffer_size, | 1022 | if (plugin_buffer_handle <= 0) |
1022 | &dummy_ops); | 1023 | { |
1024 | plugin_buffer_handle = core_alloc_maximum("plugin audio buf", | ||
1025 | &plugin_buffer_size, | ||
1026 | &dummy_ops); | ||
1027 | } | ||
1028 | |||
1029 | if (buffer_size) | ||
1030 | *buffer_size = plugin_buffer_size; | ||
1031 | |||
1023 | return core_get_data(plugin_buffer_handle); | 1032 | return core_get_data(plugin_buffer_handle); |
1024 | } | 1033 | } |
1025 | 1034 | ||
1026 | static void plugin_release_audio_buffer(void) | 1035 | static void plugin_release_audio_buffer(void) |
1027 | { | 1036 | { |
1028 | if (plugin_buffer_handle > 0) | 1037 | if (plugin_buffer_handle > 0) |
1038 | { | ||
1029 | plugin_buffer_handle = core_free(plugin_buffer_handle); | 1039 | plugin_buffer_handle = core_free(plugin_buffer_handle); |
1040 | plugin_buffer_size = 0; | ||
1041 | } | ||
1030 | } | 1042 | } |
1031 | 1043 | ||
1032 | /* The plugin wants to stay resident after leaving its main function, e.g. | 1044 | /* The plugin wants to stay resident after leaving its main function, e.g. |