diff --git a/src/CubicSDR.cpp b/src/CubicSDR.cpp index e6742e5..e11b766 100644 --- a/src/CubicSDR.cpp +++ b/src/CubicSDR.cpp @@ -54,8 +54,8 @@ bool CubicSDR::OnInit() { audioVisualQueue = new DemodulatorThreadOutputQueue(); audioVisualQueue->set_max_num_items(1); - threadCmdQueueSDR = new SDRThreadCommandQueue; - sdrThread = new SDRThread(threadCmdQueueSDR); + threadCmdQueueSDR = new SDRThreadCommandQueue(); + sdrThread = new SDRThread(); sdrPostThread = new SDRPostThread(); sdrPostThread->setNumVisSamples(16384 * 2); @@ -64,7 +64,8 @@ bool CubicSDR::OnInit() { iqVisualQueue = new DemodulatorThreadInputQueue; iqVisualQueue->set_max_num_items(1); - sdrThread->setIQDataOutQueue(iqPostDataQueue); + sdrThread->setInputQueue("SDRCommandQueue",threadCmdQueueSDR); + sdrThread->setOutputQueue("IQDataOutput",iqPostDataQueue); sdrPostThread->setIQDataInQueue(iqPostDataQueue); sdrPostThread->setIQVisualQueue(iqVisualQueue); diff --git a/src/sdr/SDRThread.cpp b/src/sdr/SDRThread.cpp index 99202bb..e31473c 100644 --- a/src/sdr/SDRThread.cpp +++ b/src/sdr/SDRThread.cpp @@ -3,8 +3,7 @@ #include #include "CubicSDR.h" -SDRThread::SDRThread(SDRThreadCommandQueue* pQueue) : IOThread(), - commandQueue(pQueue), iqDataOutQueue(NULL) { +SDRThread::SDRThread() : IOThread() { offset.store(0); deviceId.store(-1); dev = NULL; @@ -167,9 +166,10 @@ void SDRThread::run() { ReBuffer buffers; - while (!terminated) { - SDRThreadCommandQueue *cmdQueue = commandQueue.load(); + SDRThreadIQDataQueue* iqDataOutQueue = (SDRThreadIQDataQueue*) getOutputQueue("IQDataOutput"); + SDRThreadCommandQueue* cmdQueue = (SDRThreadCommandQueue*) getInputQueue("SDRCommandQueue"); + while (!terminated) { if (!cmdQueue->empty()) { bool freq_changed = false; bool offset_changed = false; @@ -290,8 +290,8 @@ void SDRThread::run() { double time_slice = (double) n_read / (double) sampleRate.load(); seconds += time_slice; - if (iqDataOutQueue.load() != NULL) { - iqDataOutQueue.load()->push(dataOut); + if (iqDataOutQueue != NULL) { + iqDataOutQueue->push(dataOut); } } diff --git a/src/sdr/SDRThread.h b/src/sdr/SDRThread.h index 1ddaec0..4b59d81 100644 --- a/src/sdr/SDRThread.h +++ b/src/sdr/SDRThread.h @@ -126,17 +126,13 @@ class SDRThread : public IOThread { public: rtlsdr_dev_t *dev; - SDRThread(SDRThreadCommandQueue* pQueue); + SDRThread(); ~SDRThread(); static int enumerate_rtl(std::vector *devs); void run(); - - void setIQDataOutQueue(SDRThreadIQDataQueue* iqDataQueue) { - iqDataOutQueue = iqDataQueue; - } - + int getDeviceId() const { return deviceId.load(); } @@ -148,8 +144,5 @@ public: protected: std::atomic sampleRate; std::atomic_llong offset; - std::atomic commandQueue; - std::atomic iqDataOutQueue; - std::atomic_int deviceId; };