SDRThread convert to IOThread named queue handler

This commit is contained in:
Charles J. Cliffe 2015-07-29 22:01:13 -04:00
parent 05cd99bbf1
commit 1f6276d090
3 changed files with 12 additions and 18 deletions

View File

@ -54,8 +54,8 @@ bool CubicSDR::OnInit() {
audioVisualQueue = new DemodulatorThreadOutputQueue(); audioVisualQueue = new DemodulatorThreadOutputQueue();
audioVisualQueue->set_max_num_items(1); audioVisualQueue->set_max_num_items(1);
threadCmdQueueSDR = new SDRThreadCommandQueue; threadCmdQueueSDR = new SDRThreadCommandQueue();
sdrThread = new SDRThread(threadCmdQueueSDR); sdrThread = new SDRThread();
sdrPostThread = new SDRPostThread(); sdrPostThread = new SDRPostThread();
sdrPostThread->setNumVisSamples(16384 * 2); sdrPostThread->setNumVisSamples(16384 * 2);
@ -64,7 +64,8 @@ bool CubicSDR::OnInit() {
iqVisualQueue = new DemodulatorThreadInputQueue; iqVisualQueue = new DemodulatorThreadInputQueue;
iqVisualQueue->set_max_num_items(1); iqVisualQueue->set_max_num_items(1);
sdrThread->setIQDataOutQueue(iqPostDataQueue); sdrThread->setInputQueue("SDRCommandQueue",threadCmdQueueSDR);
sdrThread->setOutputQueue("IQDataOutput",iqPostDataQueue);
sdrPostThread->setIQDataInQueue(iqPostDataQueue); sdrPostThread->setIQDataInQueue(iqPostDataQueue);
sdrPostThread->setIQVisualQueue(iqVisualQueue); sdrPostThread->setIQVisualQueue(iqVisualQueue);

View File

@ -3,8 +3,7 @@
#include <vector> #include <vector>
#include "CubicSDR.h" #include "CubicSDR.h"
SDRThread::SDRThread(SDRThreadCommandQueue* pQueue) : IOThread(), SDRThread::SDRThread() : IOThread() {
commandQueue(pQueue), iqDataOutQueue(NULL) {
offset.store(0); offset.store(0);
deviceId.store(-1); deviceId.store(-1);
dev = NULL; dev = NULL;
@ -167,9 +166,10 @@ void SDRThread::run() {
ReBuffer<SDRThreadIQData> buffers; ReBuffer<SDRThreadIQData> buffers;
while (!terminated) { SDRThreadIQDataQueue* iqDataOutQueue = (SDRThreadIQDataQueue*) getOutputQueue("IQDataOutput");
SDRThreadCommandQueue *cmdQueue = commandQueue.load(); SDRThreadCommandQueue* cmdQueue = (SDRThreadCommandQueue*) getInputQueue("SDRCommandQueue");
while (!terminated) {
if (!cmdQueue->empty()) { if (!cmdQueue->empty()) {
bool freq_changed = false; bool freq_changed = false;
bool offset_changed = false; bool offset_changed = false;
@ -290,8 +290,8 @@ void SDRThread::run() {
double time_slice = (double) n_read / (double) sampleRate.load(); double time_slice = (double) n_read / (double) sampleRate.load();
seconds += time_slice; seconds += time_slice;
if (iqDataOutQueue.load() != NULL) { if (iqDataOutQueue != NULL) {
iqDataOutQueue.load()->push(dataOut); iqDataOutQueue->push(dataOut);
} }
} }

View File

@ -126,17 +126,13 @@ class SDRThread : public IOThread {
public: public:
rtlsdr_dev_t *dev; rtlsdr_dev_t *dev;
SDRThread(SDRThreadCommandQueue* pQueue); SDRThread();
~SDRThread(); ~SDRThread();
static int enumerate_rtl(std::vector<SDRDeviceInfo *> *devs); static int enumerate_rtl(std::vector<SDRDeviceInfo *> *devs);
void run(); void run();
void setIQDataOutQueue(SDRThreadIQDataQueue* iqDataQueue) {
iqDataOutQueue = iqDataQueue;
}
int getDeviceId() const { int getDeviceId() const {
return deviceId.load(); return deviceId.load();
} }
@ -148,8 +144,5 @@ public:
protected: protected:
std::atomic<uint32_t> sampleRate; std::atomic<uint32_t> sampleRate;
std::atomic_llong offset; std::atomic_llong offset;
std::atomic<SDRThreadCommandQueue*> commandQueue;
std::atomic<SDRThreadIQDataQueue*> iqDataOutQueue;
std::atomic_int deviceId; std::atomic_int deviceId;
}; };