From 166843896d049613b887c99685a7fa66cc10f652 Mon Sep 17 00:00:00 2001 From: John Melton G0ORX Date: Fri, 6 Nov 2020 14:49:51 +0000 Subject: [PATCH] add soapy_protocol_is_running function --- soapy_protocol.c | 43 ++++++++++++++++--------------------------- soapy_protocol.h | 1 + 2 files changed, 17 insertions(+), 27 deletions(-) diff --git a/soapy_protocol.c b/soapy_protocol.c index a22c437..3b0858f 100644 --- a/soapy_protocol.c +++ b/soapy_protocol.c @@ -27,11 +27,6 @@ #include "SoapySDR/Formats.h" #include "SoapySDR/Version.h" -//#define TIMING -#ifdef TIMING -#include -#endif - #include "band.h" #include "channel.h" #include "discovered.h" @@ -69,10 +64,6 @@ static gpointer receive_thread(gpointer data); static int actual_rate; -#ifdef TIMING -static int rate_samples; -#endif - static gboolean running; static int mic_sample_divisor=1; @@ -198,6 +189,13 @@ g_print("soapy_protocol_create_transmitter: SoapySDRDevice_setupStream: channel= g_print("soapy_protocol_create_transmitter: max_tx_samples=%d\n",max_tx_samples); output_buffer=(float *)malloc(max_tx_samples*sizeof(float)*2); + if(radio->local_microphone) { + if(audio_open_input(radio)!=0) { + fprintf(stderr,"audio_open_input failed\n"); + radio->local_microphone=FALSE; + } + } + } void soapy_protocol_start_transmitter(TRANSMITTER *tx) { @@ -254,12 +252,6 @@ static void *receive_thread(void *arg) { long long timeNs=0; long timeoutUs=100000L; int i; -#ifdef TIMING - struct timeval tv; - long start_time, end_time; - rate_samples=0; - gettimeofday(&tv, NULL); start_time=tv.tv_usec + 1000000 * tv.tv_sec; -#endif RECEIVER *rx=(RECEIVER *)arg; float *buffer=g_new(float,max_samples*2); void *buffs[]={buffer}; @@ -269,6 +261,8 @@ g_print("%s: receive_thread\n",__FUNCTION__); elements=SoapySDRDevice_readStream(soapy_device,rx_stream,buffs,max_samples,&flags,&timeNs,timeoutUs); if(elements<0) { g_print("%s: elements=%d max_samples=%d\n",__FUNCTION__,elements,max_samples); + running=FALSE; + break; } for(i=0;ibuffer[i*2]=(double)buffer[i*2]; @@ -321,15 +315,6 @@ g_print("resampler: elements in=%d out=%d\n",elements,out_elements); } else { add_iq_samples(rx,isample,qsample); } -#ifdef TIMING - rate_samples++; - if(rate_samples>=rx->sample_rate) { - gettimeofday(&tv, NULL); end_time=tv.tv_usec + 1000000 * tv.tv_sec; - g_print("%d samples in %ld usec\n",rx->sample_rate,end_time-start_time); - rate_samples=0; - start_time=end_time; - } -#endif } } } @@ -338,9 +323,9 @@ g_print("%s: receive_thread: SoapySDRDevice_deactivateStream\n",__FUNCTION__); SoapySDRDevice_deactivateStream(soapy_device,rx_stream,0,0LL); g_print("%s: receive_thread: SoapySDRDevice_closeStream\n",__FUNCTION__); SoapySDRDevice_closeStream(soapy_device,rx_stream); -g_print("%s: receive_thread: SoapySDRDevice_unmake\n",__FUNCTION__); - SoapySDRDevice_unmake(soapy_device); - _exit(0); +//g_print("%s: receive_thread: SoapySDRDevice_unmake\n",__FUNCTION__); +// SoapySDRDevice_unmake(soapy_device); + //_exit(0); } void soapy_protocol_process_local_mic(RADIO *r) { @@ -490,3 +475,7 @@ void soapy_protocol_set_automatic_gain(RECEIVER *rx,gboolean mode) { char *soapy_protocol_read_sensor(char *name) { return SoapySDRDevice_readSensor(soapy_device, name); } + +gboolean soapy_protocol_is_running() { + return running; +} diff --git a/soapy_protocol.h b/soapy_protocol.h index 95b6248..4de2a9a 100644 --- a/soapy_protocol.h +++ b/soapy_protocol.h @@ -47,4 +47,5 @@ void soapy_protocol_process_local_mic(RADIO *r); void soapy_protocol_iq_samples(float isample,float qsample); void soapy_protocol_set_mic_sample_rate(int rate); char *soapy_protocol_read_sensor(char *name); +gboolean soapy_protocol_is_running(); #endif