Fix Aero OSS Slot Preemption Issues; #127

This commit is contained in:
lwvmobile
2023-06-11 03:09:32 -04:00
parent 79b4a5e720
commit 330ebe2bf3
6 changed files with 53 additions and 63 deletions

View File

@@ -374,7 +374,7 @@ typedef struct
uint8_t trunk_tune_enc_calls;
//OSS audio - slot preference
uint8_t slot_preference;
int slot_preference;
//'DSP' Format Output
uint8_t use_dsp_output;

View File

@@ -1365,7 +1365,7 @@ main (int argc, char **argv)
}
#ifdef AERO_BUILD
fprintf (stderr, "Build Version: v2.1 Win32 \n");
fprintf (stderr, "Build Version: v2.1 Win32 \n");
#else
fprintf (stderr, "Build Version: %s \n", GIT_TAG);
#endif
@@ -1452,14 +1452,13 @@ main (int argc, char **argv)
break;
case 'z':
sscanf (optarg, "%c", &opts.slot_preference);
opts.slot_preference--; //user inputs 1 or 2, internally we want 0 and 1
sscanf (optarg, "%d", &opts.slot_preference);
if (opts.slot_preference > 0) opts.slot_preference--; //user inputs 1 or 2, internally we want 0 and 1
if (opts.slot_preference > 1) opts.slot_preference = 1;
fprintf (stderr, "TDMA (DMR and P2) Slot Voice Preference is Slot %d. \n", opts.slot_preference+1);
break;
//Enable Audio Smoothing for Upsampled Audio
case '0':
case 'V':
state.audio_smoothing = 1;
break;
@@ -2491,58 +2490,60 @@ main (int argc, char **argv)
opts.playoffset = 0;
opts.playoffsetR = 0;
opts.delay = 0;
if (strlen(opts.wav_out_file) > 0 && opts.dmr_stereo_wav == 0)
{
openWavOutFile (&opts, &state);
}
//open wav file should be handled directly by the -w switch now
// if (strlen(opts.wav_out_file) > 0 && opts.dmr_stereo_wav == 0)
// {
// openWavOutFile (&opts, &state);
// }
opts.pulse_digi_rate_out = 48000;
opts.pulse_digi_out_channels = 1;
if (opts.audio_out_type == 0) openPulseOutput(&opts);
if (opts.audio_out_type == 5) openAudioOutDevice (&opts, SAMPLE_RATE_OUT);
}
//this particular if-elseif-else could be rewritten to be a lot neater and simpler
else if (strcmp (opts.audio_in_dev, opts.audio_out_dev) != 0)
{
opts.split = 1;
opts.playoffset = 0;
opts.playoffsetR = 0;
opts.delay = 0;
if (strlen(opts.wav_out_file) > 0 && opts.dmr_stereo_wav == 0)
{
openWavOutFile (&opts, &state);
}
else
{
openAudioOutDevice (&opts, SAMPLE_RATE_OUT);
}
//open wav file should be handled directly by the -w switch now
// if (strlen(opts.wav_out_file) > 0 && opts.dmr_stereo_wav == 0)
// openWavOutFile (&opts, &state);
// else
openAudioInDevice (&opts);
fprintf (stderr,"Press CTRL + C to close.\n");
// fprintf (stderr,"Press CTRL + C to close.\n");
}
else
else
{
opts.split = 0;
opts.playoffset = 25;
opts.playoffsetR = 25;
opts.playoffset = 0; //not sure what the playoffset actually does for us
opts.playoffsetR = 0;
opts.delay = 0;
openAudioInDevice (&opts);
opts.audio_out_fd = opts.audio_in_fd;
// opts.audio_out_fd = opts.audio_in_fd; //not sure that this really does much anymore, other than cause problems
}
if (opts.playfiles == 1)
if (opts.playfiles == 1)
{
state.aout_gain = 25; //BUGFIX: No audio output when playing back .amb/.imb files
playMbeFiles (&opts, &state, argc, argv);
}
else
else
{
liveScanner (&opts, &state);
}
cleanupAndExit (&opts, &state);
cleanupAndExit (&opts, &state);
return (0);
return (0);
}

View File

@@ -1037,7 +1037,7 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
#ifdef AERO_BUILD //FUN FACT: OSS stutters only on Cygwin, using padsp in linux, it actually opens two virtual /dev/dsp audio streams for output
//OSS Specific Voice Preemption if dual voices on TDMA and one slot has preference over the other
if (opts->slot_preference == 1 && opts->audio_out_type == 5 && opts->audio_out == 1 && state->dmrburstR == 16)
if (opts->slot_preference == 1 && opts->audio_out_type == 5 && opts->audio_out == 1 && (state->dmrburstR == 16 || state->dmrburstR == 21) )
{
opts->audio_out = 0;
preempt = 1;
@@ -1107,7 +1107,7 @@ processMbeFrame (dsd_opts * opts, dsd_state * state, char imbe_fr[8][23], char a
#ifdef AERO_BUILD //FUN FACT: OSS stutters only on Cygwin, using padsp in linux, it actually opens two virtual /dev/dsp audio streams for output
//OSS Specific Voice Preemption if dual voices on TDMA and one slot has preference over the other
if (opts->slot_preference == 0 && opts->audio_out_type == 5 && opts->audio_out == 1 && state->dmrburstL == 16)
if (opts->slot_preference == 0 && opts->audio_out_type == 5 && opts->audio_out == 1 && (state->dmrburstL == 16 || state->dmrburstL == 21) )
{
opts->audio_out = 0;
preempt = 1;

View File

@@ -114,22 +114,22 @@ char * DMRBusrtTypes[32] = {
"R-S ERR ",
"CRC ERR ",
"NULL ",
"Voice ",
"VOICE",
" ",
"INIT ",
"INIT ",
"MAC PTT", //20
"MAC ACTIVE", //21
"MAC HANGTIME", //22
"MAC PTT END", //23
"MAC IDLE", //24
"PTT", //20 MAC
"VOICE", //21 MAC_ACTIVE
"HANGTIME", //22 MAC
"PTT END", //23 MAC
"IDLE", //24 MAC
"HDU",
"VOICE LDU", //26
"VOICE LDU",
"TDU/TDULC",
"VOICE", //26 LDU1
"VOICE", //27 LDU2
"TDU/LC",
"TSBK",
"MAC SIGNAL",
"MAC SIGNAL"
"SIGNAL", //MAC_SIGNAL
"SIGNAL" //MAC_SIGNAL
};
@@ -2218,7 +2218,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
}
if (opts->audio_in_type == 5)
{
printw ("| OSS Audio Input: [%2i] kHz [1] Channel\n", SAMPLE_RATE_IN);
printw ("| OSS Audio Input: [%2i] kHz [1] Channel\n", SAMPLE_RATE_IN/1000);
}
if (opts->audio_in_type == 4)
{
@@ -2262,7 +2262,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
}
if (opts->audio_out_type == 5)
{
printw ("| OSS Audio Output: [%2i] kHz [1] Channel", SAMPLE_RATE_IN);
printw ("| OSS Audio Output: [%2i] kHz [1] Channel", SAMPLE_RATE_OUT/1000);
if (state->audio_smoothing == 1) printw (" - Smoothing On");
printw (" \n");
}
@@ -2651,7 +2651,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
#ifdef AERO_BUILD //FUN FACT: OSS stutters only on Cygwin, using padsp in linux, it actually opens two virtual /dev/dsp audio streams for output
//
if (opts->slot_preference == 1 && opts->audio_out_type == 5 && opts->audio_out == 1 && state->dmrburstR == 16 && state->dmrburstL == 16) printw ("*M*");
if (opts->slot_preference == 1 && opts->audio_out_type == 5 && opts->audio_out == 1 && ( state->dmrburstL == 16 || state->dmrburstL == 21) && (state->dmrburstR == 16 || state->dmrburstR == 21)) printw ("*M*");
//
#endif
@@ -2853,7 +2853,7 @@ ncursesPrinter (dsd_opts * opts, dsd_state * state)
printw ("%s ", DMRBusrtTypes[state->dmrburstR]);
#ifdef AERO_BUILD //FUN FACT: OSS stutters only on Cygwin, using padsp in linux, it actually opens two virtual /dev/dsp audio streams for output
//
if (opts->slot_preference == 0 && opts->audio_out_type == 5 && opts->audio_out == 1 && state->dmrburstR == 16 && state->dmrburstL == 16) printw ("*M*");
if (opts->slot_preference == 0 && opts->audio_out_type == 5 && opts->audio_out == 1 && ( state->dmrburstL == 16 || state->dmrburstL == 21) && (state->dmrburstR == 16 || state->dmrburstR == 21) ) printw ("*M*");
//
#endif
printw ("\n");

View File

@@ -479,9 +479,9 @@ void process_4V (dsd_opts * opts, dsd_state * state)
//Cygwin OSS Slot Preference Pre-emption shim
if (opts->audio_out_type == 5)
{
//set to 16 for MBE OSS shim to preempt audio
if (state->currentslot == 0) state->dmrburstL = 16;
else state->dmrburstR = 16;
//set to 21 for MBE OSS shim to preempt audio
if (state->currentslot == 0) state->dmrburstL = 21;
else state->dmrburstR = 21;
}
#endif
@@ -646,9 +646,9 @@ void process_2V (dsd_opts * opts, dsd_state * state)
//Cygwin OSS Slot Preference Pre-emption shim
if (opts->audio_out_type == 5)
{
//set to 16 for MBE OSS shim to preempt audio
if (state->currentslot == 0) state->dmrburstL = 16;
else state->dmrburstR = 16;
//set to 21 for MBE OSS shim to preempt audio
if (state->currentslot == 0) state->dmrburstL = 21;
else state->dmrburstR = 21;
}
#endif
@@ -885,16 +885,5 @@ void processP2 (dsd_opts * opts, dsd_state * state)
state->dmr_stereo = 0;
state->p2_is_lcch = 0;
//bugfix for OSS slot preferred pre-emption on dual voices
//in case or marginal signal or bad decoding and both get stuck on 16, indefinitely muting the non-preferred slot
//BUG: This causes an annoying blink blink in ncurses, just FYI -- find a better workaround
#ifdef AERO_BUILD
if (opts->audio_out_type == 5)
{
//set both to blank value
state->dmrburstL = 17;
state->dmrburstR = 17;
}
#endif
fprintf (stderr, "\n");
}

View File

@@ -276,13 +276,13 @@ void process_SACCH_MAC_PDU (dsd_opts * opts, dsd_state * state, int payload[180]
{
if (state->currentslot == 1)
{
state->dmrburstL = 21;
state->dmrburstL = 22;
//close any open MBEout files
if (opts->mbe_out_f != NULL) closeMbeOutFile (opts, state);
}
else
{
state->dmrburstR = 21;
state->dmrburstR = 22;
//close any open MBEout files
if (opts->mbe_out_fR != NULL) closeMbeOutFileR (opts, state);
}