From 4f012390c0b91753ea5937ef9aa81f1305b24718 Mon Sep 17 00:00:00 2001 From: lwvmobile <59371473+lwvmobile@users.noreply.github.com> Date: Tue, 8 Feb 2022 13:04:29 -0500 Subject: [PATCH] More Pulse Audio Tinkering More Pulse Audio Tinkering Had to disable Monitor Source Input (Was working in Arch, but with some latency/buffer issues, makes LM pulse server crash/restart?) --- include/dsd.h | 2 +- src/dsd_audio.c | 14 ++++++++++---- src/dsd_frame_sync.c | 1 + src/dsd_main.c | 6 ++++-- 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/include/dsd.h b/include/dsd.h index fc10e1f..5b627d2 100644 --- a/include/dsd.h +++ b/include/dsd.h @@ -150,6 +150,7 @@ typedef struct int pulse_raw_rate_out; int pulse_digi_rate_in; int pulse_digi_rate_out; + int pulse_flush; pa_simple *pulse_raw_dev_in; pa_simple *pulse_raw_dev_out; pa_simple *pulse_digi_dev_in; @@ -308,7 +309,6 @@ void processDMRdata (dsd_opts * opts, dsd_state * state); void processDMRvoice (dsd_opts * opts, dsd_state * state); void processAudio (dsd_opts * opts, dsd_state * state); void playRawAudio (dsd_opts * opts, dsd_state * state); //added this one HERE HERE -void processRawAudio (dsd_opts * opts, dsd_state * state); //added this one HERE HERE void openPulseInput (dsd_opts * opts); //not sure if we need to just pass opts, or opts and state yet void openPulseOutput (dsd_opts * opts); //not sure if we need to just pass opts, or opts and state yet void writeSynthesizedVoice (dsd_opts * opts, dsd_state * state); diff --git a/src/dsd_audio.c b/src/dsd_audio.c index e793568..2c89ead 100644 --- a/src/dsd_audio.c +++ b/src/dsd_audio.c @@ -68,7 +68,7 @@ void openPulseInput(dsd_opts * opts) void playRawAudio(dsd_opts * opts, dsd_state * state) { short obuf, outl, i, sample2, something; - something = state->samplesPerSymbol / 1; //this was 5 in OSS, changed to 1 for pulse audio, no idea how it affects Port Audio + something = state->samplesPerSymbol / 1; //was this what it was? if (opts->audio_in_type == 0 && opts->audio_out_type == 0){ //hack, but might as well for this particular type since its nearly perfect for (i=0; i < something; i++){ @@ -396,12 +396,18 @@ playSynthesizedVoice (dsd_opts * opts, dsd_state * state) #endif } - else{ - pa_simple_flush(opts->pulse_raw_dev_out, NULL); + else { + if (opts->monitor_input_audio == 1){ + pa_simple_flush(opts->pulse_raw_dev_in, NULL); + pa_simple_flush(opts->pulse_raw_dev_out, NULL); + } + pa_simple_write(opts->pulse_digi_dev_out, (state->audio_out_buf_p - state->audio_out_idx), (state->audio_out_idx * 2), NULL); //Yay! It works. - state->audio_out_idx = 0; } + state->audio_out_idx = 0; } + } + if (state->audio_out_idx2 >= 800000) { state->audio_out_float_buf_p = state->audio_out_float_buf + 100; diff --git a/src/dsd_frame_sync.c b/src/dsd_frame_sync.c index 971746f..bb6da85 100644 --- a/src/dsd_frame_sync.c +++ b/src/dsd_frame_sync.c @@ -189,6 +189,7 @@ getFrameSync (dsd_opts * opts, dsd_state * state) { playRawAudio(opts, state); //this is on line 21 in dsd_audio.c } + t++; symbol = getSymbol (opts, state, 0); diff --git a/src/dsd_main.c b/src/dsd_main.c index 04723cd..e2c4d6c 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -192,6 +192,7 @@ initOpts (dsd_opts * opts) opts->pulse_raw_rate_out = 48000; opts->pulse_digi_rate_in = 48000; opts->pulse_digi_rate_out = 48000; //need to copy this to rtl type in and change rate out to 8000 + opts->pulse_flush = 1; //set 0 to flush, 1 for flushed } void @@ -681,8 +682,9 @@ main (int argc, char **argv) break; case 'W': //monitor_input_audio if no sync - opts.monitor_input_audio = 1; - printf ("Monitor Source Audio if no sync detected (WIP!)\n"); + opts.monitor_input_audio = 0; + //printf ("Monitor Source Audio if no sync detected (WIP!)\n"); + printf ("Monitor Source Audio Currently Disabled in Pulse Audio Builds.\n"); break;