From c4294f79856d28ac9c049a194853b59d0784f8c4 Mon Sep 17 00:00:00 2001 From: c vw Date: Mon, 16 Mar 2020 16:42:07 +0100 Subject: [PATCH] small SOAPY fixes --- portaudio.c | 20 ++++++++++---------- radio.c | 2 +- sliders.c | 2 +- soapy_discovery.c | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/portaudio.c b/portaudio.c index 9fcc8d2..2ed083c 100644 --- a/portaudio.c +++ b/portaudio.c @@ -47,7 +47,7 @@ AUDIO_DEVICE output_devices[MAX_AUDIO_DEVICES]; int n_input_devices=0; int n_output_devices=0; -#define BUFFER_SIZE 256 +#define MY_AUDIO_BUFFER_SIZE 256 // // Ring buffer for "local microphone" samples @@ -165,7 +165,7 @@ int audio_open_input() return -1; } - framesPerBuffer = BUFFER_SIZE; // is this for either protocol + framesPerBuffer = MY_AUDIO_BUFFER_SIZE; // is this for either protocol bzero( &inputParameters, sizeof( inputParameters ) ); //not necessary if you are filling in all the fields inputParameters.channelCount = 1; // MONO @@ -280,7 +280,7 @@ int audio_open_output(RECEIVER *rx) { PaError err; PaStreamParameters outputParameters; - long framesPerBuffer=BUFFER_SIZE; + long framesPerBuffer=MY_AUDIO_BUFFER_SIZE; int padev; int i; @@ -317,7 +317,7 @@ int audio_open_output(RECEIVER *rx) // Do not use call-back function, just stream it - rx->local_audio_buffer=g_new(float,BUFFER_SIZE); + rx->local_audio_buffer=g_new(float,MY_AUDIO_BUFFER_SIZE); rx->local_audio_buffer_offset=0; err = Pa_OpenStream(&(rx->playback_handle), NULL, &outputParameters, 48000.0, framesPerBuffer, paNoFlag, NULL, NULL); if (err != paNoError || rx->local_audio_buffer == NULL) { @@ -340,8 +340,8 @@ int audio_open_output(RECEIVER *rx) } // Write one buffer to avoid under-flow errors // (this gives us 5 msec to pass before we have to call audio_write the first time) - bzero(rx->local_audio_buffer, (size_t) BUFFER_SIZE*sizeof(float)); - Pa_WriteStream(rx->playback_handle, rx->local_audio_buffer, (unsigned long) BUFFER_SIZE); + bzero(rx->local_audio_buffer, (size_t) MY_AUDIO_BUFFER_SIZE*sizeof(float)); + Pa_WriteStream(rx->playback_handle, rx->local_audio_buffer, (unsigned long) MY_AUDIO_BUFFER_SIZE); g_mutex_unlock(&rx->local_audio_mutex); return 0; } @@ -444,8 +444,8 @@ int audio_write (RECEIVER *rx, float left, float right) g_mutex_lock(&rx->local_audio_mutex); if (rx->playback_handle != NULL && buffer != NULL) { buffer[rx->local_audio_buffer_offset++] = (left+right)*0.5; // mix to MONO - if (rx->local_audio_buffer_offset == BUFFER_SIZE) { - Pa_WriteStream(rx->playback_handle, buffer, (unsigned long) BUFFER_SIZE); + if (rx->local_audio_buffer_offset == MY_AUDIO_BUFFER_SIZE) { + Pa_WriteStream(rx->playback_handle, buffer, (unsigned long) MY_AUDIO_BUFFER_SIZE); rx->local_audio_buffer_offset=0; // do not check on errors, there will be underflows every now and then } @@ -460,8 +460,8 @@ int cw_audio_write(float sample) { if (rx->playback_handle != NULL && rx->local_audio_buffer != NULL) { buffer[rx->local_audio_buffer_offset++] = sample; - if (rx->local_audio_buffer_offset == BUFFER_SIZE) { - Pa_WriteStream(rx->playback_handle, rx->local_audio_buffer, (unsigned long) BUFFER_SIZE); + if (rx->local_audio_buffer_offset == MY_AUDIO_BUFFER_SIZE) { + Pa_WriteStream(rx->playback_handle, rx->local_audio_buffer, (unsigned long) MY_AUDIO_BUFFER_SIZE); // do not check on errors, there will be underflows every now and then rx->local_audio_buffer_offset=0; } diff --git a/radio.c b/radio.c index db675ff..4bb1d21 100644 --- a/radio.c +++ b/radio.c @@ -598,7 +598,7 @@ void start_radio() { #ifdef SOAPYSDR case SOAPYSDR_PROTOCOL: can_transmit=(radio->info.soapy.tx_channels!=0); - g_print("start_radio: can_transmit=%d tx_channels=%d\n",can_transmit,radio->info.soapy.tx_channels); + g_print("start_radio: can_transmit=%d tx_channels=%d\n",can_transmit,(int)radio->info.soapy.tx_channels); break; #endif } diff --git a/sliders.c b/sliders.c index a8308b2..46496c7 100644 --- a/sliders.c +++ b/sliders.c @@ -368,7 +368,7 @@ void set_af_gain(int rx,double value) { static void rf_gain_value_changed_cb(GtkWidget *widget, gpointer data) { active_receiver->rf_gain=gtk_range_get_value(GTK_RANGE(af_gain_scale)); #ifdef SOAPYSDR - if(protocol=SOAPYSDR_PROTOCOL) { + if(protocol==SOAPYSDR_PROTOCOL) { soapy_protocol_set_gain(active_receiver,active_receiver->rf_gain); } #endif diff --git a/soapy_discovery.c b/soapy_discovery.c index 630d34d..7ff3f27 100644 --- a/soapy_discovery.c +++ b/soapy_discovery.c @@ -263,7 +263,7 @@ void soapy_discovery() { fprintf(stderr,"soapy_discovery\n"); rtlsdr_count=0; SoapySDRKwargs *results = SoapySDRDevice_enumerate(NULL, &length); -fprintf(stderr,"soapy_discovery: length=%d\n",length); +fprintf(stderr,"soapy_discovery: length=%d\n",(int)length); for (i = 0; i < length; i++) { for (size_t j = 0; j < results[i].size; j++) { if(strcmp(results[i].keys[j],"driver")==0 && strcmp(results[i].vals[j],"audio")!=0) { -- 2.45.2