Direct all prints to STDERR

Direct all prints to STDERR
Take 2
This commit is contained in:
lwvmobile
2022-02-10 16:56:37 -05:00
committed by GitHub
parent 05b9e29724
commit fcf680a138
32 changed files with 623 additions and 626 deletions

View File

@@ -32,7 +32,7 @@ void openPulseOutput(dsd_opts * opts)
tt.format = PA_SAMPLE_S16NE;
tt.channels = 1;
tt.rate = opts->pulse_digi_rate_out; //48000, switches to 8000 when using RTL dongle
//printf("digi rate out = %d\n", opts->pulse_digi_rate_out);
//fprintf (stderr,"digi rate out = %d\n", opts->pulse_digi_rate_out);
//ss
if (opts->monitor_input_audio == 1)
@@ -117,7 +117,7 @@ void playRawAudio(dsd_opts * opts, dsd_state * state) {
if (opts->audio_out_type == 0){
//write (opts->audio_out_fd, (void*)&obuf, outl);
pa_simple_write(opts->pulse_raw_dev_out, (void*)&obuf, 2, NULL);
//printf("writing samples");
//fprintf (stderr,"writing samples");
}
#ifdef USE_PORTAUDIO //no idea if this method will work, since I can't test it
@@ -128,11 +128,11 @@ void playRawAudio(dsd_opts * opts, dsd_state * state) {
{
err = Pa_StartStream( opts->audio_out_pa_stream );
if( err != paNoError ){
printf("Can't Start PA Stream");
fprintf (stderr,"Can't Start PA Stream");
}
err = Pa_WriteStream( opts->audio_out_pa_stream, (void*)&obuf, outl );
if( err != paNoError ){
printf("Can't Write PA Stream");
fprintf (stderr,"Can't Write PA Stream");
}
}
}
@@ -287,8 +287,8 @@ writeSynthesizedVoice (dsd_opts * opts, dsd_state * state)
short *aout_buf_p;
// for(n=0; n<160; n++)
// printf("%d ", ((short*)(state->audio_out_temp_buf))[n]);
// printf("\n");
// fprintf (stderr,"%d ", ((short*)(state->audio_out_temp_buf))[n]);
// fprintf (stderr,"\n");
aout_buf_p = aout_buf;
state->audio_out_temp_buf_p = state->audio_out_temp_buf;
@@ -357,7 +357,7 @@ playSynthesizedVoice (dsd_opts * opts, dsd_state * state)
long available = Pa_GetStreamWriteAvailable( opts->audio_out_pa_stream );
if(available < 0)
err = available;
//printf("Frames available: %d\n", available);
//fprintf (stderr,"Frames available: %d\n", available);
if( err != paNoError )
break;
if(available > SAMPLE_RATE_OUT * PA_LATENCY_OUT)
@@ -365,7 +365,7 @@ playSynthesizedVoice (dsd_opts * opts, dsd_state * state)
//It looks like this might not be needed for very small latencies. However, it's definitely needed for a bit larger ones.
//When PA_LATENCY_OUT == 0.500 I get output buffer underruns if I don't use this. With PA_LATENCY_OUT <= 0.100 I don't see those happen.
//But with PA_LATENCY_OUT < 0.100 I run the risk of choppy audio and stream errors.
printf("\nSyncing voice output stream\n");
fprintf (stderr,"\nSyncing voice output stream\n");
err = Pa_StopStream( opts->audio_out_pa_stream );
if( err != paNoError )
break;
@@ -374,7 +374,7 @@ playSynthesizedVoice (dsd_opts * opts, dsd_state * state)
err = Pa_IsStreamActive( opts->audio_out_pa_stream );
if(err == 0)
{
printf("Start voice output stream\n");
fprintf (stderr,"Start voice output stream\n");
err = Pa_StartStream( opts->audio_out_pa_stream );
}
else if(err == 1)
@@ -391,9 +391,9 @@ playSynthesizedVoice (dsd_opts * opts, dsd_state * state)
if( err != paNoError )
{
fprintf( stderr, "An error occured while using the portaudio output stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
fprintf (stderr, stderr, "An error occured while using the portaudio output stream\n" );
fprintf (stderr, stderr, "Error number: %d\n", err );
fprintf (stderr, stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
}
#endif
@@ -421,20 +421,20 @@ playSynthesizedVoice (dsd_opts * opts, dsd_state * state)
int getPADevice(char* dev, int input, PaStream** stream)
{
int devnum = atoi(dev + 3);
printf("Using portaudio device %d.\n", devnum);
fprintf (stderr,"Using portaudio device %d.\n", devnum);
PaError err;
int numDevices = Pa_GetDeviceCount();
if( numDevices < 0 )
{
printf( "ERROR: Pa_GetDeviceCount returned 0x%x\n", numDevices );
fprintf (stderr, "ERROR: Pa_GetDeviceCount returned 0x%x\n", numDevices );
err = numDevices;
goto error;
}
if( devnum >= numDevices)
{
printf( "ERROR: Requested device %d is larger than number of devices.\n", devnum );
fprintf (stderr, "ERROR: Requested device %d is larger than number of devices.\n", devnum );
return(1);
}
@@ -445,19 +445,19 @@ int getPADevice(char* dev, int input, PaStream** stream)
{ /* Use wide char on windows, so we can show UTF-8 encoded device names */
wchar_t wideName[MAX_PATH];
MultiByteToWideChar(CP_UTF8, 0, deviceInfo->name, -1, wideName, MAX_PATH-1);
wprintf( L"Name = %s\n", wideName );
wprintf ( L"Name = %s\n", wideName );
}
#else
printf( "Name = %s\n", deviceInfo->name );
fprintf (stderr, "Name = %s\n", deviceInfo->name );
#endif
if((input == 1) && (deviceInfo->maxInputChannels == 0))
{
printf( "ERROR: Requested device %d is not an input device.\n", devnum );
fprintf (stderr, "ERROR: Requested device %d is not an input device.\n", devnum );
return(1);
}
if((input == 0) && (deviceInfo->maxOutputChannels == 0))
{
printf( "ERROR: Requested device %d is not an output device.\n", devnum );
fprintf (stderr, "ERROR: Requested device %d is not an output device.\n", devnum );
return(1);
}
@@ -484,9 +484,9 @@ int getPADevice(char* dev, int input, PaStream** stream)
return 0;
error:
fprintf( stderr, "An error occured while initializing a portaudio stream\n" );
fprintf( stderr, "Error number: %d\n", err );
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
fprintf (stderr, stderr, "An error occured while initializing a portaudio stream\n" );
fprintf (stderr, stderr, "Error number: %d\n", err );
fprintf (stderr, stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
return err;
}
#endif
@@ -509,7 +509,7 @@ openAudioOutDevice (dsd_opts * opts, int speed)
if(err != 0)
exit(err);
#else
printf("Error, Portaudio support not compiled.\n");
fprintf (stderr,"Error, Portaudio support not compiled.\n");
exit(1);
#endif
}
@@ -522,14 +522,14 @@ openAudioOutDevice (dsd_opts * opts, int speed)
struct stat stat_buf;
if(stat(opts->audio_out_dev, &stat_buf) != 0 && strncmp(opts->audio_out_dev, "pulse", 5 != 0)) //HERE
{
printf("Error, couldn't open %s\n", opts->audio_out_dev);
fprintf (stderr,"Error, couldn't open %s\n", opts->audio_out_dev);
exit(1);
}
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
printf("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);
}
/*
@@ -539,7 +539,7 @@ openAudioOutDevice (dsd_opts * opts, int speed)
opts->audio_out_fd = open (opts->audio_out_dev, O_WRONLY);
if (opts->audio_out_fd == -1)
{
printf ("Error, couldn't open %s\n", opts->audio_out_dev);
fprintf (stderr,"Error, couldn't open %s\n", opts->audio_out_dev);
//exit (1);
}
@@ -556,7 +556,7 @@ openAudioOutDevice (dsd_opts * opts, int speed)
if (ioctl (opts->audio_out_fd, AUDIO_SETINFO, &aset) == -1)
{
printf ("Error setting sample device parameters\n");
fprintf (stderr,"Error setting sample device parameters\n");
exit (1);
}
#endif
@@ -568,7 +568,7 @@ openAudioOutDevice (dsd_opts * opts, int speed)
opts->audio_out_fd = open (opts->audio_out_dev, O_WRONLY);
if (opts->audio_out_fd == -1)
{
printf ("Error, couldn't open %s\n", opts->audio_out_dev);
fprintf (stderr,"Error, couldn't open %s\n", opts->audio_out_dev);
opts->audio_out = 0;
//exit(1);
}
@@ -576,28 +576,28 @@ openAudioOutDevice (dsd_opts * opts, int speed)
fmt = 0;
if (ioctl (opts->audio_out_fd, SNDCTL_DSP_RESET) < 0)
{
printf ("ioctl reset error \n");
fprintf (stderr,"ioctl reset error \n");
}
fmt = speed;
if (ioctl (opts->audio_out_fd, SNDCTL_DSP_SPEED, &fmt) < 0)
{
printf ("ioctl speed error \n");
fprintf (stderr,"ioctl speed error \n");
}
fmt = 0;
if (ioctl (opts->audio_out_fd, SNDCTL_DSP_STEREO, &fmt) < 0)
{
printf ("ioctl stereo error \n");
fprintf (stderr,"ioctl stereo error \n");
}
fmt = AFMT_S16_LE;
if (ioctl (opts->audio_out_fd, SNDCTL_DSP_SETFMT, &fmt) < 0)
{
printf ("ioctl setfmt error \n");
fprintf (stderr,"ioctl setfmt error \n");
}
#endif
*/
}
printf ("Audio Out Device: %s\n", opts->audio_out_dev);
fprintf (stderr,"Audio Out Device: %s\n", opts->audio_out_dev);
}
void
@@ -616,7 +616,7 @@ openAudioInDevice (dsd_opts * opts)
opts->audio_in_file = sf_open_fd(fileno(stdin), SFM_READ, opts->audio_in_file_info, 0);
if(opts->audio_in_file == NULL) {
printf ("Error, couldn't open stdin with libsndfile: %s\n", sf_strerror(NULL));
fprintf (stderr,"Error, couldn't open stdin with libsndfile: %s\n", sf_strerror(NULL));
exit(1); //had this one disabled, re-enabling it now
}
}
@@ -636,7 +636,7 @@ openAudioInDevice (dsd_opts * opts)
}
#else
printf("Error, Portaudio support not compiled.\n");
fprintf (stderr,"Error, Portaudio support not compiled.\n");
exit(1);
#endif
}
@@ -653,7 +653,7 @@ openAudioInDevice (dsd_opts * opts)
struct stat stat_buf;
if (stat(opts->audio_in_dev, &stat_buf) != 0)
{
printf("Error, couldn't open %s\n", opts->audio_in_dev);
fprintf (stderr,"Error, couldn't open %s\n", opts->audio_in_dev);
exit(1);
}
if (S_ISREG(stat_buf.st_mode))
@@ -667,7 +667,7 @@ openAudioInDevice (dsd_opts * opts)
if(opts->audio_in_file == NULL)
{
printf ("Error, couldn't open file %s\n", opts->audio_in_dev);
fprintf (stderr,"Error, couldn't open file %s\n", opts->audio_in_dev);
exit(1);
}
}
@@ -692,7 +692,7 @@ openAudioInDevice (dsd_opts * opts)
}
if (opts->audio_in_fd == -1)
{
printf ("Error, couldn't open %s\n", opts->audio_in_dev);
fprintf (stderr,"Error, couldn't open %s\n", opts->audio_in_dev);
//exit(1);
}
@@ -712,7 +712,7 @@ openAudioInDevice (dsd_opts * opts)
if (ioctl (opts->audio_in_fd, AUDIO_SETINFO, &aset) == -1)
{
printf ("Error setting sample device parameters\n");
fprintf (stderr,"Error setting sample device parameters\n");
exit (1);
}
#endif
@@ -732,29 +732,29 @@ openAudioInDevice (dsd_opts * opts)
if (opts->audio_in_fd == -1)
{
printf ("Error, couldn't open %s\n", opts->audio_in_dev);
fprintf (stderr,"Error, couldn't open %s\n", opts->audio_in_dev);
opts->audio_out = 0;
}
fmt = 0;
if (ioctl (opts->audio_in_fd, SNDCTL_DSP_RESET) < 0)
{
printf ("ioctl reset error \n");
fprintf (stderr,"ioctl reset error \n");
}
fmt = SAMPLE_RATE_IN;
if (ioctl (opts->audio_in_fd, SNDCTL_DSP_SPEED, &fmt) < 0)
{
printf ("ioctl speed error \n");
fprintf (stderr,"ioctl speed error \n");
}
fmt = 0;
if (ioctl (opts->audio_in_fd, SNDCTL_DSP_STEREO, &fmt) < 0)
{
printf ("ioctl stereo error \n");
fprintf (stderr,"ioctl stereo error \n");
}
fmt = AFMT_S16_LE;
if (ioctl (opts->audio_in_fd, SNDCTL_DSP_SETFMT, &fmt) < 0)
{
printf ("ioctl setfmt error \n");
fprintf (stderr,"ioctl setfmt error \n");
}
#endif
*/
@@ -763,10 +763,10 @@ openAudioInDevice (dsd_opts * opts)
if (opts->split == 1)
{
printf ("Audio In Device: %s\n", opts->audio_in_dev);
fprintf (stderr,"Audio In Device: %s\n", opts->audio_in_dev);
}
else
{
printf ("Audio In/Out Device: %s\n", opts->audio_in_dev);
fprintf (stderr,"Audio In/Out Device: %s\n", opts->audio_in_dev);
}
}