summaryrefslogtreecommitdiff
path: root/apps/plugins/lua/tlsf_helper.c
diff options
context:
space:
mode:
authorWilliam Wilgus <me.theuser@yahoo.com>2019-07-12 05:23:52 -0500
committerWilliam Wilgus <me.theuser@yahoo.com>2019-07-28 15:17:48 +0200
commit45bd14b392622cb58e967a24e4652c510b3d43e4 (patch)
tree22bd2e5cafc2d82ecc4773f83de7f86515b4db43 /apps/plugins/lua/tlsf_helper.c
parent4beafe16fafc2e5c59734ef065a6f8d23766520d (diff)
downloadrockbox-45bd14b392622cb58e967a24e4652c510b3d43e4.tar.gz
rockbox-45bd14b392622cb58e967a24e4652c510b3d43e4.zip
Lua Add Emergency Garbage Collector
Derivative of work by RobertGabrielJakabosky http://lua-users.org/wiki/EmergencyGarbageCollector I've only implemented the not enough memory part and expanded this idea to adding a mechanism to signal the OOM condition of the plugin buffer which allows us to only grab the playback buffer after garbage collection fails (SO THE MUSIC KEEPS PLAYING AS LONG AS POSSIBLE) Change-Id: I684fb98b540ffc01f7ba324ab5b761ceb59b9f9b
Diffstat (limited to 'apps/plugins/lua/tlsf_helper.c')
-rw-r--r--apps/plugins/lua/tlsf_helper.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/apps/plugins/lua/tlsf_helper.c b/apps/plugins/lua/tlsf_helper.c
index edf32eecf9..097d39c8e4 100644
--- a/apps/plugins/lua/tlsf_helper.c
+++ b/apps/plugins/lua/tlsf_helper.c
@@ -20,6 +20,7 @@
20 20
21#include "plugin.h" 21#include "plugin.h"
22#include <tlsf.h> 22#include <tlsf.h>
23#include "lua.h"
23 24
24void *get_new_area(size_t *size) 25void *get_new_area(size_t *size)
25{ 26{
@@ -36,7 +37,8 @@ void *get_new_area(size_t *size)
36 return pluginbuf_ptr; 37 return pluginbuf_ptr;
37 } 38 }
38 39
39 if (audiobuf_ptr == NULL) 40 /* only grab the next area if lua already tried + failed to garbage collect*/
41 if (audiobuf_ptr == NULL && (get_lua_OOM())->count > 0)
40 { 42 {
41 /* grab audiobuffer */ 43 /* grab audiobuffer */
42 audiobuf_ptr = rb->plugin_get_audio_buffer(size); 44 audiobuf_ptr = rb->plugin_get_audio_buffer(size);