Add Error Handling and Error String on Pulse Input and Output Opening #259 ; Change Input 'Name' on M17 Voice Input so it doesn't default to same source as RF Signal Input;

This commit is contained in:
lwvmobile 2024-05-06 21:46:29 -04:00
parent 79d5b795e3
commit ef94b311fa
3 changed files with 33 additions and 2 deletions

View File

@ -59,7 +59,7 @@ find_package(PulseAudio REQUIRED)
find_package(CODEC2)
include_directories(SYSTEM ${LIBSNDFILE_INCLUDE_DIR} ${MBE_INCLUDE_DIR} ${ITPP_INCLUDE_DIR} ${PULSEAUDIO_INCLUDE_DIRS} ${CURSES_INCLUDE_DIR})
set(LIBS ${MBE_LIBRARY} ${LIBSNDFILE_LIBRARY} ${ITPP_LIBRARY} ${PULSEAUDIO_SIMPLE_LIBRARY} ${CURSES_LIBRARY})
set(LIBS ${MBE_LIBRARY} ${LIBSNDFILE_LIBRARY} ${ITPP_LIBRARY} ${PULSEAUDIO_SIMPLE_LIBRARY} ${PULSEAUDIO_LIBRARY} ${CURSES_LIBRARY})
if(RTLSDR_FOUND)
find_package(Threads)

View File

@ -63,6 +63,7 @@
#include <pulse/simple.h> //PULSE AUDIO
#include <pulse/error.h> //PULSE AUDIO
#include <pulse/introspect.h> //PULSE AUDIO
#define SAMPLE_RATE_IN 48000 //48000
#define SAMPLE_RATE_OUT 8000 //8000

View File

@ -41,6 +41,8 @@ void closePulseInput (dsd_opts * opts)
void openPulseOutput(dsd_opts * opts)
{
int err;
ss.format = PA_SAMPLE_S16NE;
ss.channels = opts->pulse_raw_out_channels;
ss.rate = opts->pulse_raw_rate_out;
@ -57,20 +59,41 @@ void openPulseOutput(dsd_opts * opts)
if (opts->frame_provoice == 1 || opts->monitor_input_audio == 1)
opts->pulse_raw_dev_out = pa_simple_new(NULL, "DSD-FME3", PA_STREAM_PLAYBACK, NULL, "Analog", &ss, 0, NULL, NULL);
if (err < 0)
{
fprintf (stderr, "%s", pa_strerror(err));
exit(0);
}
pa_channel_map* fl = 0; //NULL and 0 are same in this context
pa_channel_map* ss = 0; //NULL and 0 are same in this context
if (opts->floating_point == 0)
opts->pulse_digi_dev_out = pa_simple_new(NULL, "DSD-FME", PA_STREAM_PLAYBACK, NULL, opts->output_name, &tt, ss, NULL, NULL);
if (err < 0)
{
fprintf (stderr, "%s", pa_strerror(err));
exit(0);
}
if (opts->floating_point == 1)
{
opts->pulse_digi_dev_out = pa_simple_new(NULL, "DSD-FME", PA_STREAM_PLAYBACK, NULL, opts->output_name, &ff, fl, NULL, NULL);
if (err < 0)
{
fprintf (stderr, "%s", pa_strerror(err));
exit(0);
}
}
}
void openPulseInput(dsd_opts * opts)
{
int err;
cc.format = PA_SAMPLE_S16NE;
cc.channels = opts->pulse_digi_in_channels;
cc.rate = opts->pulse_digi_rate_in; //48000
@ -94,8 +117,15 @@ void openPulseInput(dsd_opts * opts)
lt.maxlength = -1;
lt.prebuf = -1;
lt.tlength = -1;
if (opts->m17encoder == 1)
opts->pulse_digi_dev_in = pa_simple_new(NULL, "DSD-FME4", PA_STREAM_RECORD, NULL, "M17 Voice Input", &cc, NULL, &lt, &err);
else opts->pulse_digi_dev_in = pa_simple_new(NULL, "DSD-FME", PA_STREAM_RECORD, NULL, opts->output_name, &cc, NULL, &lt, &err);
opts->pulse_digi_dev_in = pa_simple_new(NULL, "DSD-FME", PA_STREAM_RECORD, NULL, opts->output_name, &cc, NULL, &lt, NULL);
if (err < 0)
{
fprintf (stderr, "%s", pa_strerror(err));
exit(0);
}
//debug
// if (opts->m17encoder == 1)