mirror of
https://github.com/radio95-rnt/fm95.git
synced 2026-07-29 15:59:14 +02:00
rds input via ipc - experimental (hence it is on 61.75 - the only unused frequncy
This commit is contained in:
@@ -6,8 +6,7 @@
|
||||
#include <pthread.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
static int make_server_socket(const char *path)
|
||||
{
|
||||
static int make_server_socket(const char *path) {
|
||||
int fd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (fd < 0) { perror("ipc: socket"); return -1; }
|
||||
|
||||
@@ -63,13 +62,11 @@ static void *listener_thread(void *arg) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int create_ipc(ipc_ctx_t *ctx, ipc_client_fn handler,
|
||||
const char *socket_path, void *user_data)
|
||||
{
|
||||
ctx->handler = handler;
|
||||
ctx->user_data = user_data;
|
||||
ctx->running = 1;
|
||||
ctx->server_fd = make_server_socket(socket_path);
|
||||
int create_ipc(ipc_ctx_t *ctx, ipc_client_fn handler, const char *socket_path, void *user_data) {
|
||||
ctx->handler = handler;
|
||||
ctx->user_data = user_data;
|
||||
ctx->running = 1;
|
||||
ctx->server_fd = make_server_socket(socket_path);
|
||||
ctx->socket_path = strdup(socket_path);
|
||||
if (ctx->server_fd < 0) return -1;
|
||||
|
||||
|
||||
+5
-2
@@ -30,7 +30,10 @@ float get_oscillator_cos_multiplier_ni(Oscillator *osc, float multiplier) {
|
||||
return cosf(osc->phase * multiplier);
|
||||
}
|
||||
|
||||
inline void advance_oscillator(Oscillator *osc) {
|
||||
inline bool advance_oscillator(Oscillator *osc) {
|
||||
osc->phase += osc->phase_increment;
|
||||
if (osc->phase >= M_2PI) osc->phase -= M_2PI;
|
||||
if (osc->phase >= M_2PI) {
|
||||
osc->phase -= M_2PI;
|
||||
return true;
|
||||
} return false;
|
||||
}
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "constants.h"
|
||||
#include <stdbool.h>
|
||||
#include <math.h>
|
||||
|
||||
typedef struct {
|
||||
@@ -15,4 +16,4 @@ float get_oscillator_sin_sample(Oscillator *osc);
|
||||
float get_oscillator_cos_sample(Oscillator *osc);
|
||||
float get_oscillator_sin_multiplier_ni(Oscillator *osc, float multiplier);
|
||||
float get_oscillator_cos_multiplier_ni(Oscillator *osc, float multiplier);
|
||||
void advance_oscillator(Oscillator *osc);
|
||||
bool advance_oscillator(Oscillator *osc);
|
||||
Reference in New Issue
Block a user