From 56a5df86a04db1407944ba3f310613114ba380f1 Mon Sep 17 00:00:00 2001 From: lwvmobile Date: Fri, 28 Jul 2023 17:25:16 -0400 Subject: [PATCH] Fix Some Slot Preference Clashes; --- src/dsd_main.c | 6 +++++- src/dsd_ncurses.c | 31 +++++++++++++++++++++++++++---- 2 files changed, 32 insertions(+), 5 deletions(-) diff --git a/src/dsd_main.c b/src/dsd_main.c index 60f7509..65b1f8a 100644 --- a/src/dsd_main.c +++ b/src/dsd_main.c @@ -1194,8 +1194,10 @@ usage () printf (" -Q Specify Filename for OK-DMRlib Structured File Output. (placed in DSP folder)\n"); printf (" -c Output symbol capture to .bin file\n"); printf (" -q Reverse Mute - Mute Unencrypted Voice and Unmute Encrypted Voice\n"); - // printf (" -V Enable Audio Smoothing on Upsampled 48k/1 or 24k/2 Audio (Capital V)\n"); printf (" -V Enable TDMA Voice Synthesis on Slot 1 (1), Slot 2 (2), or Both (3); Default is 3; \n"); + // #ifdef AERO_BUILD + printf (" If using /dev/dsp input and output at 48k1, launch two instances of DSD-FME w -V 1 and -V 2 if needed"); + // #endif printf (" (Audio Smoothing is now disabled on all upsampled output by default -- fix crackle/buzz bug)\n"); printf (" -z Set TDMA Voice Slot Preference when using /dev/dsp audio output (prevent lag and stuttering)\n"); printf (" -y Enable Experimental Pulse Audio Float Audio Output\n"); @@ -1644,6 +1646,8 @@ main (int argc, char **argv) if (opts.slot2_on == 1) fprintf (stderr, "on Slot 2"); if (slotson == 0) fprintf (stderr, "Disabled"); + //disable slot preference if not 1 or 2 + if (slotson == 1 || slotson == 2) opts.slot_preference = 3; fprintf (stderr, "\n"); break; diff --git a/src/dsd_ncurses.c b/src/dsd_ncurses.c index b2ba585..a6f45f2 100644 --- a/src/dsd_ncurses.c +++ b/src/dsd_ncurses.c @@ -3484,18 +3484,30 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) ncursesMenu (opts, state); //just a quick test } + //toggling when 48k/1 OSS still has some lag -- needed to clear out the buffer when switching if (c == 49) // '1' key, toggle slot1 on { //switching, but want to control each seperately plz if (opts->slot1_on == 1) { opts->slot1_on = 0; - // opts->slot_preference = 1; + opts->slot_preference = 1; //slot 2 + //clear any previously buffered audio + state->audio_out_float_buf_p = state->audio_out_float_buf + 100; + state->audio_out_buf_p = state->audio_out_buf + 100; + memset (state->audio_out_float_buf, 0, 100 * sizeof (float)); + memset (state->audio_out_buf, 0, 100 * sizeof (short)); + state->audio_out_idx2 = 0; + state->audio_out_idx = 0; } else if (opts->slot1_on == 0) { opts->slot1_on = 1; - // opts->slot_preference = 0; + if (opts->audio_out_type == 5) //OSS 48k/1 + { + opts->slot_preference = 0; //slot 1 + opts->slot2_on = 0; //turn off slot 2 + } } } @@ -3505,12 +3517,23 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state) if (opts->slot2_on == 1) { opts->slot2_on = 0; - // opts->slot_preference = 1; + opts->slot_preference = 0; //slot 1 + //clear any previously buffered audio + state->audio_out_float_buf_pR = state->audio_out_float_bufR + 100; + state->audio_out_buf_pR = state->audio_out_bufR + 100; + memset (state->audio_out_float_bufR, 0, 100 * sizeof (float)); + memset (state->audio_out_bufR, 0, 100 * sizeof (short)); + state->audio_out_idx2R = 0; + state->audio_out_idxR = 0; } else if (opts->slot2_on == 0) { opts->slot2_on = 1; - // opts->slot_preference = 0; + if (opts->audio_out_type == 5) //OSS 48k/1 + { + opts->slot_preference = 1; //slot 2 + opts->slot1_on = 0; //turn off slot 1 + } } }