Mute Audio Option (-o null)

This commit is contained in:
lwvmobile
2022-09-26 19:13:49 -04:00
parent ad4013d7d2
commit cb84f7469e
3 changed files with 44 additions and 22 deletions

View File

@@ -526,18 +526,18 @@ openAudioOutDevice (dsd_opts * opts, int speed)
else else
{ {
struct stat stat_buf; struct stat stat_buf;
if(stat(opts->audio_out_dev, &stat_buf) != 0 && strncmp(opts->audio_out_dev, "pulse", 5 != 0)) //HERE // if(stat(opts->audio_out_dev, &stat_buf) != 0 && strncmp(opts->audio_out_dev, "pulse", 5 != 0)) //HERE
{ // {
fprintf (stderr,"Error, couldn't open %s\n", opts->audio_out_dev); // fprintf (stderr,"Error, couldn't open %s\n", opts->audio_out_dev);
exit(1); // exit(1);
} // }
if( (!(S_ISCHR(stat_buf.st_mode) || S_ISBLK(stat_buf.st_mode))) && strncmp(opts->audio_out_dev, "pulse", 5 != 0)) // if( (!(S_ISCHR(stat_buf.st_mode) || S_ISBLK(stat_buf.st_mode))) && strncmp(opts->audio_out_dev, "pulse", 5 != 0))
{ // {
// this is not a device // // this is not a device
fprintf (stderr,"Error, %s is not a device. use -w filename for wav output.\n", opts->audio_out_dev); // fprintf (stderr,"Error, %s is not a device. use -w filename for wav output.\n", opts->audio_out_dev);
exit(1); // exit(1);
} // }
} }
fprintf (stderr,"Audio Out Device: %s\n", opts->audio_out_dev); fprintf (stderr,"Audio Out Device: %s\n", opts->audio_out_dev);
} }

View File

@@ -1596,12 +1596,18 @@ main (int argc, char **argv)
if((strncmp(opts.audio_in_dev, "pulse", 5) == 0)) if((strncmp(opts.audio_in_dev, "pulse", 5) == 0))
{ {
opts.audio_in_type == 0; opts.audio_in_type = 0;
} }
if((strncmp(opts.audio_out_dev, "pulse", 5) == 0)) if((strncmp(opts.audio_out_dev, "pulse", 5) == 0))
{ {
opts.audio_out_type == 0; opts.audio_out_type = 0;
}
if((strncmp(opts.audio_out_dev, "null", 4) == 0))
{
opts.audio_out_type = 9; //9 for NULL, or mute output
opts.audio_out = 0; //turn off so we won't playSynthesized
} }
if (opts.playfiles == 1) if (opts.playfiles == 1)

View File

@@ -189,15 +189,15 @@ void beeper (dsd_opts * opts, dsd_state * state, int type)
if (loop == 1) if (loop == 1)
{ {
//only beep on R if dmr_stereo is active and slot 2, else beep on L //only beep on R if dmr_stereo is active and slot 2, else beep on L
if (type == 0 && state->dmr_stereo == 1) if (type == 0 && state->dmr_stereo == 1 && opts->audio_out == 1)
{ {
pa_simple_write(opts->pulse_digi_dev_out, buf, sizeof(buf), NULL); pa_simple_write(opts->pulse_digi_dev_out, buf, sizeof(buf), NULL);
} }
if (type == 1 && state->dmr_stereo == 1) if (type == 1 && state->dmr_stereo == 1 && opts->audio_out == 1)
{ {
pa_simple_write(opts->pulse_digi_dev_outR, buf, sizeof(buf), NULL); pa_simple_write(opts->pulse_digi_dev_outR, buf, sizeof(buf), NULL);
} }
if (state->dmr_stereo == 0) if (state->dmr_stereo == 0 && opts->audio_out == 1)
{ {
pa_simple_write(opts->pulse_digi_dev_out, buf, sizeof(buf), NULL); pa_simple_write(opts->pulse_digi_dev_out, buf, sizeof(buf), NULL);
} }
@@ -256,7 +256,7 @@ char *choicesc[] = {
"Setup and Start RTL Input ", "Setup and Start RTL Input ",
"Retune RTL Dongle ", "Retune RTL Dongle ",
" ", " ",
" ", //removing options no longer necesary or not recommended "Toggle Audio Mute ", //removing options no longer necesary or not recommended
"Toggle NCurses Compact Mode", "Toggle NCurses Compact Mode",
"Toggle NCurses Call History", "Toggle NCurses Call History",
"Stop All Decoded WAV Saving", "Stop All Decoded WAV Saving",
@@ -380,8 +380,11 @@ void ncursesOpen (dsd_opts * opts, dsd_state * state)
//ncursesMenu //ncursesMenu
void ncursesMenu (dsd_opts * opts, dsd_state * state) void ncursesMenu (dsd_opts * opts, dsd_state * state)
{ {
// state->menuopen = 1; //flag the menu is open, stop processing getFrameSync //close pulse output if not null output
closePulseOutput (opts); if (opts->audio_out == 1 && opts->audio_out_type == 0)
{
closePulseOutput (opts);
}
if (opts->audio_in_type == 0) //close pulse input if it is the specified input method if (opts->audio_in_type == 0) //close pulse input if it is the specified input method
{ {
@@ -707,7 +710,16 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
if (choicec == 9) if (choicec == 9)
{ {
//vacant box if (opts->audio_out == 0)
{
opts->audio_out = 1;
opts->audio_out_type = 0;
}
else
{
opts->audio_out = 0;
opts->audio_out_type = 9;
}
} }
if (choicec == 10) if (choicec == 10)
@@ -1451,8 +1463,12 @@ void ncursesMenu (dsd_opts * opts, dsd_state * state)
refresh(); refresh();
state->menuopen = 0; //flag the menu is closed, resume processing getFrameSync state->menuopen = 0; //flag the menu is closed, resume processing getFrameSync
//reopen pulse output with new parameters //reopen pulse output with new parameters, if not null output type
openPulseOutput (opts); if (opts->audio_out == 1 && opts->audio_out_type == 0)
{
openPulseOutput (opts);
}
if (opts->audio_in_type == 0) //reopen pulse input if it is the specified input method if (opts->audio_in_type == 0) //reopen pulse input if it is the specified input method
{ {