mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-07-30 00:39:15 +02:00
bug fixes
This commit is contained in:
+4
-1
@@ -7,11 +7,12 @@ lua_State *L = NULL;
|
||||
static pthread_mutex_t lua_mutex;
|
||||
|
||||
#define lua_registertotable(L,n,f) (lua_pushcfunction(L, (f)), lua_setfield(L, -2, (n)))
|
||||
void init_lua(RDSEncoder* _enc) {
|
||||
uint8_t init_lua(RDSEncoder* _enc) {
|
||||
static int mutex_initialized = 0;
|
||||
enc = _enc;
|
||||
L = luaL_newstate();
|
||||
printf("Initializing %s\n", LUA_COPYRIGHT);
|
||||
if(L == NULL) return 0;
|
||||
|
||||
luaL_requiref(L, "_G", luaopen_base, 1);
|
||||
luaL_requiref(L, LUA_STRLIBNAME, luaopen_string, 1);
|
||||
@@ -162,6 +163,8 @@ void init_lua(RDSEncoder* _enc) {
|
||||
pthread_mutex_init(&lua_mutex, NULL);
|
||||
mutex_initialized = 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void run_lua(char *str, size_t str_len, char *cmd_output, size_t *out_len) {
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
#include <lualib.h>
|
||||
#include <lauxlib.h>
|
||||
|
||||
void init_lua(RDSEncoder* _enc);
|
||||
uint8_t init_lua(RDSEncoder* _enc);
|
||||
void run_lua(char *str, size_t str_len, char *cmd_output, size_t* out_len);
|
||||
int lua_group(RDSGroup* group, const char grp);
|
||||
int lua_rds2_group(RDSGroup* group, int stream);
|
||||
|
||||
@@ -97,16 +97,16 @@ void get_rds_group(RDSEncoder* enc, RDSGroup *group, uint8_t stream) {
|
||||
time(&now);
|
||||
utc = gmtime(&now);
|
||||
|
||||
if(utc->tm_sec != enc->state[enc->program].last_second) {
|
||||
if(utc->tm_sec != enc->state[enc->program].last_second && stream == 0) {
|
||||
enc->state[enc->program].last_second = utc->tm_sec;
|
||||
lua_call_tfunction("tick");
|
||||
}
|
||||
|
||||
if (utc->tm_min != enc->state[enc->program].last_minute) {
|
||||
if (utc->tm_min != enc->state[enc->program].last_minute && stream == 0) {
|
||||
enc->state[enc->program].last_minute = utc->tm_min;
|
||||
lua_call_tfunction("minute_tick");
|
||||
|
||||
if(enc->data[enc->program].ct && stream == 0) {
|
||||
if(enc->data[enc->program].ct) {
|
||||
get_rdsp_ct_group(group, now);
|
||||
goto group_coded;
|
||||
}
|
||||
|
||||
+4
-1
@@ -169,7 +169,10 @@ int main(int argc, char **argv) {
|
||||
RDSModulator rdsModulator = {0};
|
||||
|
||||
RDSEncoder rdsEncoder = {0};
|
||||
init_lua(&rdsEncoder);
|
||||
if(init_lua(&rdsEncoder) == 1) {
|
||||
fprintf(stderr, "Could not create lua state - not enough memory\n");
|
||||
goto exit;
|
||||
}
|
||||
init_rds_modulator(&rdsModulator, &rdsEncoder, config.num_streams);
|
||||
init_rds_encoder(&rdsEncoder);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user