diff options
author | William Wilgus <me.theuser@yahoo.com> | 2019-07-12 05:23:52 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2019-07-28 15:17:48 +0200 |
commit | 45bd14b392622cb58e967a24e4652c510b3d43e4 (patch) | |
tree | 22bd2e5cafc2d82ecc4773f83de7f86515b4db43 /apps/plugins/lua/lua_user.c | |
parent | 4beafe16fafc2e5c59734ef065a6f8d23766520d (diff) | |
download | rockbox-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/lua_user.c')
-rw-r--r-- | apps/plugins/lua/lua_user.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/apps/plugins/lua/lua_user.c b/apps/plugins/lua/lua_user.c new file mode 100644 index 0000000000..8d77dcdf3f --- /dev/null +++ b/apps/plugins/lua/lua_user.c | |||
@@ -0,0 +1,18 @@ | |||
1 | #include "plugin.h" | ||
2 | #include "lstate.h" | ||
3 | #include LUA_USER_H | ||
4 | |||
5 | /* lua Out Of Memory */ | ||
6 | static struct lua_OOM l_oom = {NULL, 0}; | ||
7 | |||
8 | int set_lua_OOM(lua_State * L) | ||
9 | { | ||
10 | l_oom.L = L; | ||
11 | l_oom.count++; | ||
12 | return 0; | ||
13 | } | ||
14 | |||
15 | struct lua_OOM *get_lua_OOM(void) | ||
16 | { | ||
17 | return &l_oom; | ||
18 | } | ||