A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd

lua add ability to pass PLUGIN_ ret vals with os.exit() + add defines

Change-Id: I45998245271fbd8fee4534f8497b014025e4dcc7

+29 -3
+1
apps/plugins/lua/rbdefines_helper.pl
··· 50 50 '^SYS_(TIMEOUT|POWEROFF|BATTERY_UPDATE)$', 51 51 '^SYS_USB_(DIS|)CONNECTED$', 52 52 '^HOME_DIR$', 53 + '^PLUGIN(_OK|_USB_CONNECTED|_POWEROFF|_GOTO_WPS|_GOTO_PLUGIN)$', 53 54 '^PLUGIN_DIR$', 54 55 '^PLUGIN(_APPS_|_GAMES_|_)DATA_DIR$', 55 56 '^ROCKBOX_DIR$',
+9 -3
apps/plugins/lua/rocklua.c
··· 175 175 static void lua_atexit(void) 176 176 { 177 177 char *filename; 178 - 178 + int err_n; 179 179 if(Ls && lua_gettop(Ls) > 1) 180 180 { 181 + err_n = lua_tointeger(Ls, -1); /* os.exit? */ 181 182 if (Ls == lua_touserdata(Ls, -1)) /* signal from restart_lua */ 182 183 { 183 184 filename = (char *) malloc((MAX_PATH * 2) + 1); ··· 195 196 free(filename); 196 197 plugin_start(NULL); 197 198 } 198 - else if (lua_tointeger(Ls, -1) != 0) /* os.exit */ 199 + else if (err_n >= PLUGIN_USB_CONNECTED) /* INTERNAL PLUGIN RETVAL */ 200 + { 201 + lua_close(Ls); 202 + _exit(err_n); /* don't call exit handler */ 203 + } 204 + else if (err_n != 0) 199 205 { 200 206 ERR_RUN: 201 207 lu_status = LUA_ERRRUN; ··· 205 211 else 206 212 lua_close(Ls); 207 213 } 208 - _exit(0); /* don't call exit handler */ 214 + _exit(PLUGIN_OK); /* don't call exit handler */ 209 215 } 210 216 211 217 /* split filename at argchar
+19
apps/plugins/lua_scripts/return2WPS.lua
··· 1 + --[[ 2 + __________ __ ___. 3 + Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 + Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 + Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 + Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 + \/ \/ \/ \/ \/ 8 + $Id$ 9 + Example Lua Return to WPS on exit 10 + Copyright (C) 2021 William Wilgus 11 + This program is free software; you can redistribute it and/or 12 + modify it under the terms of the GNU General Public License 13 + as published by the Free Software Foundation; either version 2 14 + of the License, or (at your option) any later version. 15 + This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 16 + KIND, either express or implied. 17 + ]]-- 18 + 19 + os.exit(rb.PLUGIN_GOTO_WPS)