mirror of
https://github.com/radio95-rnt/rds95.git
synced 2026-02-27 04:43:52 +01:00
total control over rds2 in lua
This commit is contained in:
@@ -177,12 +177,11 @@ INT_SETTER(rt_type)
|
||||
INT_GETTER(rt_type)
|
||||
|
||||
int lua_set_rds2_mode(lua_State *localL) {
|
||||
if (!lua_isboolean(localL, 1)) return luaL_error(localL, "boolean expected, got %s", luaL_typename(localL, 1));
|
||||
mod->enc->encoder_data.rds2_mode = lua_toboolean(localL, 1);
|
||||
mod->enc->encoder_data.rds2_mode = luaL_checkinteger(localL, 1);
|
||||
return 0;
|
||||
}
|
||||
int lua_get_rds2_mode(lua_State *localL) {
|
||||
lua_pushboolean(localL, mod->enc->encoder_data.rds2_mode);
|
||||
lua_pushinteger(localL, mod->enc->encoder_data.rds2_mode);
|
||||
return 1;
|
||||
}
|
||||
int lua_set_rds_streams(lua_State *localL) {
|
||||
@@ -601,10 +600,7 @@ int lua_group(RDSGroup* group, const char grp) {
|
||||
|
||||
if (lua_isfunction(L, -1)) {
|
||||
lua_pushstring(L, &grp);
|
||||
lua_pushinteger(L, group->b);
|
||||
lua_pushinteger(L, group->c);
|
||||
lua_pushinteger(L, group->d);
|
||||
if (lua_pcall(L, 4, 4, 0) == LUA_OK) {
|
||||
if (lua_pcall(L, 1, 4, 0) == LUA_OK) {
|
||||
if (!lua_isboolean(L, -1)) {
|
||||
pthread_mutex_unlock(&lua_mutex);
|
||||
return 0;
|
||||
@@ -636,6 +632,41 @@ int lua_group(RDSGroup* group, const char grp) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int lua_rds2_group(RDSGroup* group, int stream) {
|
||||
pthread_mutex_lock(&lua_mutex);
|
||||
lua_getglobal(L, "rds2_group");
|
||||
|
||||
if (lua_isfunction(L, -1)) {
|
||||
lua_pushinteger(L, stream);
|
||||
if (lua_pcall(L, 1, 4, 0) == LUA_OK) {
|
||||
if (!lua_isinteger(L, -1)) {
|
||||
pthread_mutex_unlock(&lua_mutex);
|
||||
return 0;
|
||||
}
|
||||
if (!lua_isinteger(L, -2)) {
|
||||
pthread_mutex_unlock(&lua_mutex);
|
||||
return 0;
|
||||
}
|
||||
if (!lua_isinteger(L, -3)) {
|
||||
pthread_mutex_unlock(&lua_mutex);
|
||||
return 0;
|
||||
}
|
||||
if (!lua_isinteger(L, -4)) {
|
||||
pthread_mutex_unlock(&lua_mutex);
|
||||
return 0;
|
||||
}
|
||||
group->d = luaL_checkinteger(L, -1);
|
||||
group->c = luaL_checkinteger(L, -2);
|
||||
group->b = luaL_checkinteger(L, -3);
|
||||
group->a = luaL_checkinteger(L, -4);
|
||||
lua_pop(L, 3);
|
||||
} else fprintf(stderr, "Lua error: %s at 'rds2_group'\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) {
|
||||
pthread_mutex_lock(&lua_mutex);
|
||||
lua_rawgeti(L, LUA_REGISTRYINDEX, ref);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
void init_lua(RDSModulator* rds_mod);
|
||||
void run_lua(char *str, char *cmd_output);
|
||||
int lua_group(RDSGroup* group, const char grp);
|
||||
int lua_rds2_group(RDSGroup* group, int stream);
|
||||
void lua_call_function_nolock(const char* function);
|
||||
void lua_call_function(const char* function);
|
||||
void lua_group_ref(RDSGroup* group, int ref);
|
||||
|
||||
@@ -245,6 +245,10 @@ static void get_rds_group(RDSEncoder* enc, RDSGroup *group, uint8_t stream) {
|
||||
|
||||
get_rds_sequence_group(enc, group, &grp, stream);
|
||||
|
||||
goto group_coded_rds2;
|
||||
} else if(enc->encoder_data.rds2_mode == 2) {
|
||||
lua_rds2_group(group, stream);
|
||||
if(group->a == 0) group->is_type_b = (IS_TYPE_B(group->b) != 0);
|
||||
goto group_coded_rds2;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
#include "common.h"
|
||||
#define LUA_USER_DATA 1024
|
||||
#define LUA_USER_DATA 1280
|
||||
|
||||
/* The RDS error-detection code generator polynomial is
|
||||
* x^10 + x^8 + x^7 + x^5 + x^4 + x^3 + x^0
|
||||
@@ -183,8 +183,7 @@ typedef struct {
|
||||
} RDSState;
|
||||
|
||||
typedef struct {
|
||||
uint16_t special_features;
|
||||
uint8_t rds2_mode : 1;
|
||||
uint8_t rds2_mode : 2;
|
||||
// uint8_t rds2_buffer[16384];
|
||||
} RDSEncoderData;
|
||||
typedef struct {
|
||||
|
||||
Reference in New Issue
Block a user