mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-11-23 12:18:37 -05:00
SDRThread convert to IOThread named queue handler
This commit is contained in:
parent
05cd99bbf1
commit
1f6276d090
@ -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);
|
||||
|
||||
|
@ -3,8 +3,7 @@
|
||||
#include <vector>
|
||||
#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<SDRThreadIQData> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,17 +126,13 @@ class SDRThread : public IOThread {
|
||||
public:
|
||||
rtlsdr_dev_t *dev;
|
||||
|
||||
SDRThread(SDRThreadCommandQueue* pQueue);
|
||||
SDRThread();
|
||||
~SDRThread();
|
||||
|
||||
static int enumerate_rtl(std::vector<SDRDeviceInfo *> *devs);
|
||||
|
||||
void run();
|
||||
|
||||
void setIQDataOutQueue(SDRThreadIQDataQueue* iqDataQueue) {
|
||||
iqDataOutQueue = iqDataQueue;
|
||||
}
|
||||
|
||||
|
||||
int getDeviceId() const {
|
||||
return deviceId.load();
|
||||
}
|
||||
@ -148,8 +144,5 @@ public:
|
||||
protected:
|
||||
std::atomic<uint32_t> sampleRate;
|
||||
std::atomic_llong offset;
|
||||
std::atomic<SDRThreadCommandQueue*> commandQueue;
|
||||
std::atomic<SDRThreadIQDataQueue*> iqDataOutQueue;
|
||||
|
||||
std::atomic_int deviceId;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user