mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-07-29 08:19:17 +02:00
fix logic
This commit is contained in:
+3
-3
@@ -12,7 +12,7 @@ uint8_t init_lua(RDSEncoder* _enc) {
|
||||
enc = _enc;
|
||||
L = luaL_newstate();
|
||||
printf("Initializing %s\n", LUA_COPYRIGHT);
|
||||
if(L == NULL) return 0;
|
||||
if(L == NULL) return 1;
|
||||
|
||||
luaL_requiref(L, "_G", luaopen_base, 1);
|
||||
luaL_requiref(L, LUA_STRLIBNAME, luaopen_string, 1);
|
||||
@@ -152,7 +152,7 @@ uint8_t init_lua(RDSEncoder* _enc) {
|
||||
if (luaL_loadfile(L, "/etc/rds95.lua") != LUA_OK) {
|
||||
fprintf(stderr, "Lua error loading file: %s\n", lua_tostring(L, -1));
|
||||
lua_pop(L, 1);
|
||||
return 0;
|
||||
return 2;
|
||||
} else {
|
||||
if (lua_pcall(L, 0, 0, 0) != LUA_OK) {
|
||||
printf("Init error: %s\n", lua_tostring(L, -1));
|
||||
@@ -164,7 +164,7 @@ uint8_t init_lua(RDSEncoder* _enc) {
|
||||
mutex_initialized = 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void run_lua(char *str, size_t str_len, char *cmd_output, size_t *out_len) {
|
||||
|
||||
+5
-1
@@ -169,9 +169,13 @@ int main(int argc, char **argv) {
|
||||
RDSModulator rdsModulator = {0};
|
||||
|
||||
RDSEncoder rdsEncoder = {0};
|
||||
if(init_lua(&rdsEncoder) == 1) {
|
||||
uint8_t err = init_lua(&rdsEncoder);
|
||||
if(err == 1) {
|
||||
fprintf(stderr, "Could not create lua state - not enough memory\n");
|
||||
goto exit;
|
||||
} else if (err == 2) {
|
||||
fprintf(stderr, "Could not load lua script file\n");
|
||||
goto exit;
|
||||
}
|
||||
init_rds_modulator(&rdsModulator, &rdsEncoder, config.num_streams);
|
||||
init_rds_encoder(&rdsEncoder);
|
||||
|
||||
Reference in New Issue
Block a user