diff options
| author | Thomas Martitz <kugel@rockbox.org> | 2014-04-09 09:00:36 +0200 |
|---|---|---|
| committer | Thomas Martitz <kugel@rockbox.org> | 2014-04-09 09:04:10 +0200 |
| commit | 957613420e9c4906e8bb8ac685e10fc0c24329b8 (patch) | |
| tree | 810061339f17dbe30759fc0acc7d04070ce2ed40 /apps/plugin.c | |
| parent | 924a3c48d2b1a807bd7cd3b4b1e042fd2e3d7d06 (diff) | |
| download | rockbox-957613420e9c4906e8bb8ac685e10fc0c24329b8.zip rockbox-957613420e9c4906e8bb8ac685e10fc0c24329b8.tar.gz rockbox-957613420e9c4906e8bb8ac685e10fc0c24329b8.tar.bz2 rockbox-957613420e9c4906e8bb8ac685e10fc0c24329b8.tar.xz | |
plugins: Add plugin_release_audio_buffer().
Some plugins grab the whole audio buffer and still want to start playback
somehow (e.g. random_folder_advance_config). Since 22e802e the plugin buffer
is allocated via buflib and has to be released explicitely. For these plugins
the automatic free on exit is not sufficient and they need an API function for
that.
Fixes OOM panic on random_folder_advance_config when using start
shuffled playback.
Change-Id: I0d351daa782cb829f4ff80d34c05f40a2e0c142f
Diffstat (limited to 'apps/plugin.c')
| -rw-r--r-- | apps/plugin.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/apps/plugin.c b/apps/plugin.c index f9179f3..93779d7 100644 --- a/apps/plugin.c +++ b/apps/plugin.c @@ -129,6 +129,10 @@ static int close_wrapper(int fd); static int creat_wrapper(const char *pathname, mode_t mode); #endif +static void* plugin_get_audio_buffer(size_t *buffer_size); +static void plugin_release_audio_buffer(void); +static void plugin_tsr(bool (*exit_callback)(bool)); + static const struct plugin_api rockbox_api = { /* lcd */ @@ -692,8 +696,8 @@ static const struct plugin_api rockbox_api = { mktime, #endif plugin_get_buffer, - plugin_get_audio_buffer, - plugin_tsr, + plugin_get_audio_buffer, /* defined in plugin.c */ + plugin_tsr, /* defined in plugin.c */ plugin_get_current_filename, #if defined(DEBUG) || defined(SIMULATOR) debugf, @@ -800,6 +804,7 @@ static const struct plugin_api rockbox_api = { /* new stuff at the end, sort into place next time the API gets incompatible */ + plugin_release_audio_buffer, /* defined in plugin.c */ }; static int plugin_buffer_handle; @@ -994,7 +999,7 @@ void* plugin_get_buffer(size_t *buffer_size) Playback gets stopped, to avoid conflicts. Talk buffer is stolen as well. */ -void* plugin_get_audio_buffer(size_t *buffer_size) +static void* plugin_get_audio_buffer(size_t *buffer_size) { /* dummy ops with no callbacks, needed because by * default buflib buffers can be moved around which must be avoided */ @@ -1004,10 +1009,16 @@ void* plugin_get_audio_buffer(size_t *buffer_size) return core_get_data(plugin_buffer_handle); } +static void plugin_release_audio_buffer(void) +{ + if (plugin_buffer_handle > 0) + plugin_buffer_handle = core_free(plugin_buffer_handle); +} + /* The plugin wants to stay resident after leaving its main function, e.g. runs from timer or own thread. The callback is registered to later instruct it to free its resources before a new plugin gets loaded. */ -void plugin_tsr(bool (*exit_callback)(bool)) +static void plugin_tsr(bool (*exit_callback)(bool)) { pfn_tsr_exit = exit_callback; /* remember the callback for later */ } |