0
1
mirror of https://github.com/radio95-rnt/rds95.git synced 2026-02-27 04:43:52 +01:00
This commit is contained in:
2025-03-22 20:32:35 +01:00
parent 595faa9246
commit 03797efeaf

View File

@@ -56,9 +56,7 @@ int main(int argc, char **argv) {
char control_pipe[51] = "\0"; char control_pipe[51] = "\0";
pa_simple *rds1_device; pa_simple *rds1_device;
#ifdef RDS2_DEVICE pa_simple *rds2_device;
pa_simple *rds2_device = NULL;
#endif
pa_sample_spec format; pa_sample_spec format;
pa_buffer_attr buffer; pa_buffer_attr buffer;
@@ -118,7 +116,6 @@ int main(int argc, char **argv) {
goto exit; goto exit;
} }
#ifdef RDS2_DEVICE
rds2_device = pa_simple_new( rds2_device = pa_simple_new(
NULL, NULL,
"rds95", "rds95",
@@ -134,7 +131,6 @@ int main(int argc, char **argv) {
fprintf(stderr, "Error: cannot open sound device.\n"); fprintf(stderr, "Error: cannot open sound device.\n");
goto exit; goto exit;
} }
#endif
RDSEncoder rdsEncoder; RDSEncoder rdsEncoder;
RDSModulator rdsModulator; RDSModulator rdsModulator;
@@ -162,28 +158,22 @@ int main(int argc, char **argv) {
int pulse_error; int pulse_error;
float rds1_buffer[NUM_MPX_FRAMES]; float rds1_buffer[NUM_MPX_FRAMES];
#ifdef RDS2_DEVICE
float rds2_buffer[NUM_MPX_FRAMES]; float rds2_buffer[NUM_MPX_FRAMES];
#endif
while(!stop_rds) { while(!stop_rds) {
for (uint16_t i = 0; i < NUM_MPX_FRAMES; i++) { for (uint16_t i = 0; i < NUM_MPX_FRAMES; i++) {
rds1_buffer[i] = get_rds_sample(&rdsModulator, 0); rds1_buffer[i] = get_rds_sample(&rdsModulator, 0);
#ifdef RDS2_DEVICE
rds2_buffer[i] = get_rds_sample(&rdsModulator, 1); rds2_buffer[i] = get_rds_sample(&rdsModulator, 1);
#endif
} }
if (pa_simple_write(rds1_device, rds1_buffer, sizeof(rds1_buffer), &pulse_error) != 0) { if (pa_simple_write(rds1_device, rds1_buffer, sizeof(rds1_buffer), &pulse_error) != 0) {
fprintf(stderr, "Error: could not play audio. (%s : %d)\n", pa_strerror(pulse_error), pulse_error); fprintf(stderr, "Error: could not play audio. (%s : %d)\n", pa_strerror(pulse_error), pulse_error);
break; break;
} }
#ifdef RDS2_DEVICE
if (pa_simple_write(rds2_device, rds2_buffer, sizeof(rds2_buffer), &pulse_error) != 0) { if (pa_simple_write(rds2_device, rds2_buffer, sizeof(rds2_buffer), &pulse_error) != 0) {
fprintf(stderr, "Error: could not play audio. (%s : %d)\n", pa_strerror(pulse_error), pulse_error); fprintf(stderr, "Error: could not play audio. (%s : %d)\n", pa_strerror(pulse_error), pulse_error);
break; break;
} }
#endif
} }
exit: exit:
@@ -194,9 +184,7 @@ exit:
pthread_attr_destroy(&attr); pthread_attr_destroy(&attr);
pa_simple_free(rds1_device); pa_simple_free(rds1_device);
#ifdef RDS2_DEVICE
pa_simple_free(rds2_device); pa_simple_free(rds2_device);
#endif
return 0; return 0;
} }