summaryrefslogtreecommitdiff
path: root/apps/plugins/lua/lparser.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/lparser.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/lparser.c')
-rw-r--r--apps/plugins/lua/lparser.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/apps/plugins/lua/lparser.c b/apps/plugins/lua/lparser.c
index dda7488dca..d002e96b86 100644
--- a/apps/plugins/lua/lparser.c
+++ b/apps/plugins/lua/lparser.c
@@ -383,14 +383,18 @@ static void close_func (LexState *ls) {
383Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) { 383Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name) {
384 struct LexState lexstate; 384 struct LexState lexstate;
385 struct FuncState funcstate; 385 struct FuncState funcstate;
386 TString *tname = luaS_new(L, name);
387 setsvalue2s(L, L->top, tname); /* protect name */
388 incr_top(L);
386 lexstate.buff = buff; 389 lexstate.buff = buff;
387 luaX_setinput(L, &lexstate, z, luaS_new(L, name)); 390 luaX_setinput(L, &lexstate, z, tname);
388 open_func(&lexstate, &funcstate); 391 open_func(&lexstate, &funcstate);
389 funcstate.f->is_vararg = VARARG_ISVARARG; /* main func. is always vararg */ 392 funcstate.f->is_vararg = VARARG_ISVARARG; /* main func. is always vararg */
390 luaX_next(&lexstate); /* read first token */ 393 luaX_next(&lexstate); /* read first token */
391 chunk(&lexstate); 394 chunk(&lexstate);
392 check(&lexstate, TK_EOS); 395 check(&lexstate, TK_EOS);
393 close_func(&lexstate); 396 close_func(&lexstate);
397 L->top--; /* remove 'name' from stack */
394 lua_assert(funcstate.prev == NULL); 398 lua_assert(funcstate.prev == NULL);
395 lua_assert(funcstate.f->nups == 0); 399 lua_assert(funcstate.f->nups == 0);
396 lua_assert(lexstate.fs == NULL); 400 lua_assert(lexstate.fs == NULL);