0
1
mirror of https://github.com/radio95-rnt/rds95.git synced 2026-02-26 20:33:53 +01:00
This commit is contained in:
2025-12-24 22:26:54 +01:00
parent 39b80e113c
commit 04a7687cdd
7 changed files with 18 additions and 34 deletions

View File

@@ -65,15 +65,6 @@ int encoder_loadFromFile(RDSEncoder *enc) {
return 0;
}
int encoder_saved() {
char encoderPath[128];
snprintf(encoderPath, sizeof(encoderPath), "%s/.rdsEncoder", getenv("HOME"));
FILE *file = fopen(encoderPath, "rb");
if(!file) return 0;
fclose(file);
return 1;
}
void Modulator_saveToFile(RDSModulatorParameters *emp) {
char modulatorPath[128];
snprintf(modulatorPath, sizeof(modulatorPath), "%s/.rdsModulator", getenv("HOME"));

View File

@@ -6,7 +6,6 @@
void encoder_saveToFile(RDSEncoder *emp);
int encoder_loadFromFile(RDSEncoder *emp);
int encoder_saved();
void Modulator_saveToFile(RDSModulatorParameters *emp);
void Modulator_loadFromFile(RDSModulatorParameters *emp);

View File

@@ -586,7 +586,7 @@ void run_lua(char *str, char *cmd_output) {
pthread_mutex_unlock(&lua_mutex);
}
void lua_group(RDSGroup* group) {
int lua_group(RDSGroup* group) {
pthread_mutex_lock(&lua_mutex);
lua_getglobal(L, "group");
@@ -595,31 +595,28 @@ void lua_group(RDSGroup* group) {
lua_pushinteger(L, group->b);
lua_pushinteger(L, group->c);
lua_pushinteger(L, group->d);
if (lua_pcall(L, 3, 3, 0) == LUA_OK) {
if (lua_pcall(L, 4, 3, 0) == LUA_OK) {
if (!lua_isinteger(L, -1)) {
pthread_mutex_unlock(&lua_mutex);
return;
return 0;
}
if (!lua_isinteger(L, -2)) {
pthread_mutex_unlock(&lua_mutex);
return;
return 0;
}
if (!lua_isinteger(L, -3)) {
pthread_mutex_unlock(&lua_mutex);
return;
return 0;
}
group->d = luaL_checkinteger(L, -1);
group->c = luaL_checkinteger(L, -2);
group->b = luaL_checkinteger(L, -3);
lua_pop(L, 3);
} else {
fprintf(stderr, "Lua error: %s\n", lua_tostring(L, -1));
lua_pop(L, 1);
}
} else {
lua_pop(L, 2);
} else fprintf(stderr, "Lua error: %s\n", lua_tostring(L, -1));
lua_pop(L, 1);
}
} else lua_pop(L, 1);
pthread_mutex_unlock(&lua_mutex);
return 1;
}
void lua_group_ref(RDSGroup* group, int ref) {

View File

@@ -8,7 +8,7 @@
void init_lua(RDSModulator* rds_mod);
void run_lua(char *str, char *cmd_output);
void lua_group(RDSGroup* group);
int lua_group(RDSGroup* group);
void lua_call_function(const char* function);
void lua_group_ref(RDSGroup* group, int ref);
void destroy_lua();

View File

@@ -28,7 +28,7 @@ void get_rds_eon_group(RDSEncoder* enc, RDSGroup *group);
void get_rds_ert_group(RDSEncoder* enc, RDSGroup *group);
uint8_t get_rds_custom_groups(RDSEncoder* enc, RDSGroup *group);
uint8_t get_rds_custom_groups2(RDSEncoder* enc, RDSGroup *group);
void get_rdsp_lua_group(RDSGroup *group);
int get_rdsp_lua_group(RDSGroup *group);
void get_rds_user_oda_group(RDSEncoder* enc, RDSGroup *group);
int get_rds_user_oda_group_content(RDSEncoder* enc, RDSGroup *group);
@@ -112,7 +112,7 @@ static void get_rds_sequence_group(RDSEncoder* enc, RDSGroup *group, char* grp,
get_rds_fasttuning_group(enc, group);
break;
case 'L':
get_rdsp_lua_group(group);
if(get_rdsp_lua_group(group) == 0) get_rds_ps_group(enc, group);
break;
case 'O':
get_rds_user_oda_group(enc, group);

View File

@@ -366,9 +366,10 @@ uint8_t get_rds_custom_groups2(RDSEncoder* enc, RDSGroup *group) {
}
return 0;
}
void get_rdsp_lua_group(RDSGroup *group) {
lua_group(group);
group->is_type_b = (IS_TYPE_B(group->b) != 0);
int get_rdsp_lua_group(RDSGroup *group) {
int generated = lua_group(group);
if(generated) group->is_type_b = (IS_TYPE_B(group->b) != 0);
return generated;
}
void get_rds_user_oda_group(RDSEncoder* enc, RDSGroup *group) {

View File

@@ -39,14 +39,13 @@ void poll_udp_server() {
static char buf[BUF_SIZE];
static char cmd_buf[BUF_SIZE];
static char cmd_output[BUF_SIZE];
ssize_t bytes_read;
if (poll(&poller, 1, UDP_READ_TIMEOUT_MS) <= 0) return;
if (!(poller.revents & POLLIN)) return;
memset(buf, 0, BUF_SIZE);
client_len = sizeof(client_addr);
bytes_read = recvfrom(sockfd, buf, BUF_SIZE - 1, 0, (struct sockaddr *)&client_addr, &client_len);
ssize_t bytes_read = recvfrom(sockfd, buf, BUF_SIZE - 1, 0, (struct sockaddr *)&client_addr, &client_len);
if (bytes_read <= 0) return;
buf[bytes_read] = '\0';
@@ -62,10 +61,7 @@ void poll_udp_server() {
run_lua(cmd_buf, cmd_output);
size_t out_len = strlen(cmd_output);
if (out_len > 0) {
ssize_t sent = sendto(sockfd, cmd_output, out_len, 0, (struct sockaddr *)&client_addr, client_len);
if (sent == -1) perror("sendto");
}
if (out_len > 0 && sendto(sockfd, cmd_output, out_len, 0, (struct sockaddr *)&client_addr, client_len) == -1) perror("sendto"); // no walrus
}
token = strtok(NULL, "\r\n");
}