IOThread all the things!

This commit is contained in:
Charles J. Cliffe
2015-07-29 20:57:02 -04:00
parent 3ab8669d06
commit 05cd99bbf1
15 changed files with 128 additions and 136 deletions
+2 -6
View File
@@ -5,10 +5,9 @@
#include <vector>
#include <deque>
SDRPostThread::SDRPostThread() :
SDRPostThread::SDRPostThread() : IOThread(),
iqDataInQueue(NULL), iqDataOutQueue(NULL), iqVisualQueue(NULL), dcFilter(NULL), num_vis_samples(16384*2) {
terminated.store(false);
swapIQ.store(false);
// create a lookup table
@@ -77,10 +76,7 @@ bool SDRPostThread::getSwapIQ() {
return this->swapIQ.load();
}
void SDRPostThread::threadMain() {
int n_read;
double seconds = 0.0;
void SDRPostThread::run() {
#ifdef __APPLE__
pthread_t tID = pthread_self(); // ID of this thread
int priority = sched_get_priority_max( SCHED_FIFO) - 1;
+2 -3
View File
@@ -3,7 +3,7 @@
#include "SDRThread.h"
#include <algorithm>
class SDRPostThread {
class SDRPostThread : public IOThread {
public:
SDRPostThread();
~SDRPostThread();
@@ -21,7 +21,7 @@ public:
void setSwapIQ(bool swapIQ);
bool getSwapIQ();
void threadMain();
void run();
void terminate();
protected:
@@ -31,7 +31,6 @@ protected:
std::mutex busy_demod;
std::vector<DemodulatorInstance *> demodulators;
std::atomic_bool terminated;
iirfilt_crcf dcFilter;
int num_vis_samples;
std::atomic_bool swapIQ;
+2 -8
View File
@@ -3,9 +3,8 @@
#include <vector>
#include "CubicSDR.h"
SDRThread::SDRThread(SDRThreadCommandQueue* pQueue) :
SDRThread::SDRThread(SDRThreadCommandQueue* pQueue) : IOThread(),
commandQueue(pQueue), iqDataOutQueue(NULL) {
terminated.store(false);
offset.store(0);
deviceId.store(-1);
dev = NULL;
@@ -114,7 +113,7 @@ int SDRThread::enumerate_rtl(std::vector<SDRDeviceInfo *> *devs) {
}
void SDRThread::threadMain() {
void SDRThread::run() {
#ifdef __APPLE__
pthread_t tID = pthread_self(); // ID of this thread
int priority = sched_get_priority_max( SCHED_FIFO) - 1;
@@ -124,8 +123,6 @@ void SDRThread::threadMain() {
std::cout << "SDR thread initializing.." << std::endl;
int devCount = rtlsdr_get_device_count();
std::vector<SDRDeviceInfo *> devs;
if (deviceId == -1) {
deviceId = enumerate_rtl(&devs);
@@ -303,6 +300,3 @@ void SDRThread::threadMain() {
std::cout << "SDR thread done." << std::endl;
}
void SDRThread::terminate() {
terminated = true;
}
+2 -5
View File
@@ -122,7 +122,7 @@ public:
typedef ThreadQueue<SDRThreadCommand> SDRThreadCommandQueue;
typedef ThreadQueue<SDRThreadIQData *> SDRThreadIQDataQueue;
class SDRThread {
class SDRThread : public IOThread {
public:
rtlsdr_dev_t *dev;
@@ -131,14 +131,12 @@ public:
static int enumerate_rtl(std::vector<SDRDeviceInfo *> *devs);
void threadMain();
void run();
void setIQDataOutQueue(SDRThreadIQDataQueue* iqDataQueue) {
iqDataOutQueue = iqDataQueue;
}
void terminate();
int getDeviceId() const {
return deviceId.load();
}
@@ -153,6 +151,5 @@ protected:
std::atomic<SDRThreadCommandQueue*> commandQueue;
std::atomic<SDRThreadIQDataQueue*> iqDataOutQueue;
std::atomic_bool terminated;
std::atomic_int deviceId;
};