mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-02-26 20:33:53 +01:00
remove lua reloading
This commit is contained in:
@@ -5,13 +5,6 @@ static RDSModulator* mod = NULL;
|
||||
static lua_State *L = NULL;
|
||||
static pthread_mutex_t lua_mutex;
|
||||
static uint8_t unload_refs[33] = {LUA_REFNIL};
|
||||
static uint8_t lua_reload_scheduled = 0;
|
||||
|
||||
int lua_reload_command(lua_State* localL) {
|
||||
(void)localL;
|
||||
lua_reload_scheduled = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lua_set_rds_program_defaults(lua_State *localL) {
|
||||
(void)localL;
|
||||
@@ -479,7 +472,6 @@ void init_lua(RDSModulator* rds_mod) {
|
||||
|
||||
lua_register(L, "set_rds_program_defaults", lua_set_rds_program_defaults);
|
||||
lua_register(L, "reset_rds", lua_reset_rds);
|
||||
lua_register(L, "reload", lua_reload_command);
|
||||
|
||||
lua_register(L, "set_rds_pi", lua_set_rds_pi);
|
||||
lua_register(L, "get_rds_pi", lua_get_rds_pi);
|
||||
@@ -601,7 +593,6 @@ void init_lua(RDSModulator* rds_mod) {
|
||||
}
|
||||
|
||||
void run_lua(char *str, char *cmd_output) {
|
||||
if(lua_reload_scheduled != 0) reload_lua();
|
||||
pthread_mutex_lock(&lua_mutex);
|
||||
lua_getglobal(L, "data_handle");
|
||||
|
||||
@@ -616,7 +607,6 @@ void run_lua(char *str, char *cmd_output) {
|
||||
}
|
||||
|
||||
int lua_group(RDSGroup* group) {
|
||||
if(lua_reload_scheduled != 0) reload_lua();
|
||||
pthread_mutex_lock(&lua_mutex);
|
||||
lua_getglobal(L, "group");
|
||||
|
||||
@@ -650,7 +640,6 @@ int lua_group(RDSGroup* group) {
|
||||
}
|
||||
|
||||
void lua_group_ref(RDSGroup* group, int ref) {
|
||||
if(lua_reload_scheduled != 0) reload_lua();
|
||||
pthread_mutex_lock(&lua_mutex);
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, ref);
|
||||
|
||||
@@ -684,7 +673,6 @@ void lua_group_ref(RDSGroup* group, int ref) {
|
||||
}
|
||||
|
||||
void lua_call_function(const char* function) {
|
||||
if(lua_reload_scheduled != 0) reload_lua();
|
||||
pthread_mutex_lock(&lua_mutex);
|
||||
lua_getglobal(L, function);
|
||||
|
||||
@@ -697,32 +685,6 @@ void lua_call_function(const char* function) {
|
||||
pthread_mutex_unlock(&lua_mutex);
|
||||
}
|
||||
|
||||
void reload_lua() {
|
||||
pthread_mutex_lock(&lua_mutex);
|
||||
lua_reload_scheduled = 0;
|
||||
|
||||
lua_getglobal(L, "on_unload");
|
||||
if (lua_isfunction(L, -1)) {
|
||||
if (lua_pcall(L, 0, 0, 0) != LUA_OK) {
|
||||
fprintf(stderr, "Lua error in on_unload: %s\n", lua_tostring(L, -1));
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
} else lua_pop(L, 1);
|
||||
|
||||
for (int i = 1; i < *unload_refs; i++) {
|
||||
luaL_unref(L, LUA_REGISTRYINDEX, unload_refs[i]);
|
||||
}
|
||||
*unload_refs = 1;
|
||||
|
||||
if (L) {
|
||||
lua_close(L);
|
||||
L = NULL;
|
||||
}
|
||||
pthread_mutex_unlock(&lua_mutex);
|
||||
|
||||
init_lua(mod);
|
||||
}
|
||||
|
||||
void destroy_lua(void) {
|
||||
if (L) {
|
||||
for (int i = 1; i < *unload_refs; i++) luaL_unref(L, LUA_REGISTRYINDEX, unload_refs[i]);
|
||||
|
||||
@@ -11,5 +11,4 @@ void run_lua(char *str, char *cmd_output);
|
||||
int lua_group(RDSGroup* group);
|
||||
void lua_call_function(const char* function);
|
||||
void lua_group_ref(RDSGroup* group, int ref);
|
||||
void reload_lua();
|
||||
void destroy_lua();
|
||||
17
src/rds95.c
17
src/rds95.c
@@ -19,12 +19,6 @@
|
||||
#define NUM_MPX_FRAMES 128
|
||||
|
||||
static uint8_t stop_rds = 0;
|
||||
static volatile sig_atomic_t reload_requested = 0;
|
||||
|
||||
static void reload() {
|
||||
printf("Received an reloading signal\n");
|
||||
reload_requested = 1;
|
||||
}
|
||||
|
||||
static void stop() {
|
||||
printf("Received an stopping signal\n");
|
||||
@@ -134,19 +128,14 @@ int main(int argc, char **argv) {
|
||||
|
||||
pthread_attr_init(&attr);
|
||||
|
||||
struct sigaction sa_stop, sa_reload;
|
||||
struct sigaction sa_stop;
|
||||
|
||||
sa_stop.sa_handler = stop;
|
||||
sigemptyset(&sa_stop.sa_mask);
|
||||
sa_stop.sa_flags = 0;
|
||||
|
||||
sa_reload.sa_handler = reload;
|
||||
sigemptyset(&sa_reload.sa_mask);
|
||||
sa_reload.sa_flags = 0;
|
||||
|
||||
sigaction(SIGINT, &sa_stop, NULL);
|
||||
sigaction(SIGTERM, &sa_stop, NULL);
|
||||
sigaction(SIGHUP, &sa_reload, NULL);
|
||||
|
||||
format.format = PA_SAMPLE_FLOAT32NE;
|
||||
format.channels = config.num_streams;
|
||||
@@ -207,10 +196,6 @@ int main(int argc, char **argv) {
|
||||
fprintf(stderr, "Error: could not play audio. (%s : %d)\n", pa_strerror(pulse_error), pulse_error);
|
||||
break;
|
||||
}
|
||||
if(reload_requested) {
|
||||
reload_requested = 0;
|
||||
reload_lua();
|
||||
}
|
||||
}
|
||||
|
||||
free(rds_buffer);
|
||||
|
||||
Reference in New Issue
Block a user