af is in lua now

This commit is contained in:
2025-12-22 21:34:07 +01:00
parent f26f01e05a
commit 0848d52f88
4 changed files with 92 additions and 49 deletions
+48
View File
@@ -263,6 +263,51 @@ int lua_get_rds_grpseq(lua_State *localL) {
return 1;
}
int lua_set_rds_af_group0(lua_State *localL) {
luaL_checktype(L, 1, LUA_TTABLE);
int n = lua_rawlen(L, 1);
if (n == 0) {
memset(&(mod->enc->data[mod->enc->program].af), 0, sizeof(RDSAFs));
return 0;
}
if(n > 25) return luaL_error(L, "table length over 25");
RDSAFs new_af;
memset(&new_af, 0, sizeof(RDSAFs));
for (int i = 1; i <= n; i++) {
lua_rawgeti(L, 1, i);
if (lua_isnumber(L, -1)) add_rds_af(&new_af, lua_tonumber(L, -1));
lua_pop(L, 1);
}
memcpy(&(mod->enc->data[mod->enc->program].af), &new_af, sizeof(new_af));
return 0;
}
int lua_set_rds_af_oda(lua_State *localL) {
luaL_checktype(L, 1, LUA_TTABLE);
int n = lua_rawlen(L, 1);
if (n == 0) {
memset(&(mod->enc->data[mod->enc->program].af_oda), 0, sizeof(RDSAFsODA));
return 0;
}
if(n > 25) return luaL_error(L, "table length over 25");
RDSAFsODA new_af;
memset(&new_af, 0, sizeof(RDSAFsODA));
for (int i = 1; i <= n; i++) {
lua_rawgeti(L, 1, i);
if (lua_isnumber(L, -1)) add_rds_af_oda(&new_af, lua_tonumber(L, -1));
lua_pop(L, 1);
}
memcpy(&(mod->enc->data[mod->enc->program].af_oda), &new_af, sizeof(new_af));
return 0;
}
void init_lua(RDSModulator* rds_mod) {
mod = rds_mod;
L = luaL_newstate();
@@ -367,6 +412,9 @@ void init_lua(RDSModulator* rds_mod) {
lua_register(L, "put_rds_custom_group", lua_put_rds_custom_group);
lua_register(L, "put_rds2_custom_group", lua_put_rds2_custom_group);
lua_register(L, "set_rds_af_group0", lua_set_rds_af_group0);
lua_register(L, "set_rds_af_oda", lua_set_rds_af_oda);
}
void run_lua(char *str, char *cmd_output) {