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 -13
View File
@@ -9,11 +9,10 @@
#include "CubicSDR.h"
DemodulatorPreThread::DemodulatorPreThread(DemodulatorThreadInputQueue* iqInputQueue, DemodulatorThreadPostInputQueue* iqOutputQueue,
DemodulatorThreadControlCommandQueue *threadQueueControl, DemodulatorThreadCommandQueue* threadQueueNotify) :
DemodulatorThreadControlCommandQueue *threadQueueControl, DemodulatorThreadCommandQueue* threadQueueNotify) : IOThread(),
iqInputQueue(iqInputQueue), iqOutputQueue(iqOutputQueue), audioResampler(NULL), stereoResampler(NULL), iqResampleRatio(
1), audioResampleRatio(1), firStereoRight(NULL), firStereoLeft(NULL), iirStereoPilot(NULL), iqResampler(NULL), commandQueue(NULL), threadQueueNotify(threadQueueNotify), threadQueueControl(
threadQueueControl) {
terminated.store(false);
initialized.store(false);
freqShifter = nco_crcf_create(LIQUID_VCO);
@@ -80,11 +79,7 @@ DemodulatorPreThread::~DemodulatorPreThread() {
delete workerResults;
}
#ifdef __APPLE__
void *DemodulatorPreThread::threadMain() {
#else
void DemodulatorPreThread::threadMain() {
#endif
void DemodulatorPreThread::run() {
#ifdef __APPLE__
pthread_t tID = pthread_self(); // ID of this thread
int priority = sched_get_priority_max( SCHED_FIFO) - 1;
@@ -105,8 +100,6 @@ void DemodulatorPreThread::threadMain() {
// liquid_float_complex carrySample; // Keep the stream count even to simplify some demod operations
// bool carrySampleFlag = false;
terminated = false;
while (!terminated) {
DemodulatorThreadIQData *inp;
iqInputQueue->pop(inp);
@@ -319,10 +312,6 @@ void DemodulatorPreThread::threadMain() {
tCmd.context = this;
threadQueueNotify->push(tCmd);
std::cout << "Demodulator preprocessor thread done." << std::endl;
#ifdef __APPLE__
return this;
#endif
}
void DemodulatorPreThread::terminate() {
+2 -7
View File
@@ -7,18 +7,14 @@
#include "DemodDefs.h"
#include "DemodulatorWorkerThread.h"
class DemodulatorPreThread {
class DemodulatorPreThread : public IOThread {
public:
DemodulatorPreThread(DemodulatorThreadInputQueue* iqInputQueue, DemodulatorThreadPostInputQueue* iqOutputQueue,
DemodulatorThreadControlCommandQueue *threadQueueControl, DemodulatorThreadCommandQueue* threadQueueNotify);
~DemodulatorPreThread();
#ifdef __APPLE__
void *threadMain();
#else
void threadMain();
#endif
void run();
void setCommandQueue(DemodulatorThreadCommandQueue *tQueue) {
commandQueue = tQueue;
@@ -68,7 +64,6 @@ protected:
nco_crcf freqShifter;
int shiftFrequency;
std::atomic_bool terminated;
std::atomic_bool initialized;
DemodulatorWorkerThread *workerThread;
+2 -9
View File
@@ -12,14 +12,13 @@
#endif
DemodulatorThread::DemodulatorThread(DemodulatorThreadPostInputQueue* iqInputQueue, DemodulatorThreadControlCommandQueue *threadQueueControl,
DemodulatorThreadCommandQueue* threadQueueNotify) :
DemodulatorThreadCommandQueue* threadQueueNotify) : IOThread(),
iqInputQueue(iqInputQueue), audioVisOutputQueue(NULL), audioOutputQueue(NULL), iqAutoGain(NULL), amOutputCeil(1), amOutputCeilMA(1), amOutputCeilMAA(
1), threadQueueNotify(threadQueueNotify), threadQueueControl(threadQueueControl), squelchLevel(0), signalLevel(
0), squelchEnabled(false), audioSampleRate(0) {
stereo.store(false);
agcEnabled.store(false);
terminated.store(false);
demodulatorType.store(DEMOD_TYPE_FM);
demodFM = freqdem_create(0.5);
@@ -33,11 +32,7 @@ DemodulatorThread::DemodulatorThread(DemodulatorThreadPostInputQueue* iqInputQue
DemodulatorThread::~DemodulatorThread() {
}
#ifdef __APPLE__
void *DemodulatorThread::threadMain() {
#else
void DemodulatorThread::threadMain() {
#endif
void DemodulatorThread::run() {
#ifdef __APPLE__
pthread_t tID = pthread_self(); // ID of this thread
int priority = sched_get_priority_max( SCHED_FIFO )-1;
@@ -89,8 +84,6 @@ void DemodulatorThread::threadMain() {
break;
}
terminated = false;
while (!terminated) {
DemodulatorThreadPostIQData *inp;
iqInputQueue->pop(inp);
+2 -7
View File
@@ -10,18 +10,14 @@ typedef ThreadQueue<AudioThreadInput *> DemodulatorThreadOutputQueue;
#define DEMOD_VIS_SIZE 1024
class DemodulatorThread {
class DemodulatorThread : public IOThread {
public:
DemodulatorThread(DemodulatorThreadPostInputQueue* iqInputQueue, DemodulatorThreadControlCommandQueue *threadQueueControl,
DemodulatorThreadCommandQueue* threadQueueNotify);
~DemodulatorThread();
#ifdef __APPLE__
void *threadMain();
#else
void threadMain();
#endif
void run();
void setVisualOutputQueue(DemodulatorThreadOutputQueue *tQueue);
void setAudioOutputQueue(AudioThreadInputQueue *tQueue);
@@ -76,7 +72,6 @@ protected:
std::atomic_bool stereo;
std::atomic_bool agcEnabled;
std::atomic_bool terminated;
std::atomic_int demodulatorType;
int audioSampleRate;
+2 -3
View File
@@ -2,15 +2,14 @@
#include "CubicSDRDefs.h"
#include <vector>
DemodulatorWorkerThread::DemodulatorWorkerThread(DemodulatorThreadWorkerCommandQueue* in, DemodulatorThreadWorkerResultQueue* out) :
DemodulatorWorkerThread::DemodulatorWorkerThread(DemodulatorThreadWorkerCommandQueue* in, DemodulatorThreadWorkerResultQueue* out) : IOThread(),
commandQueue(in), resultQueue(out) {
terminated.store(false);
}
DemodulatorWorkerThread::~DemodulatorWorkerThread() {
}
void DemodulatorWorkerThread::threadMain() {
void DemodulatorWorkerThread::run() {
std::cout << "Demodulator worker thread started.." << std::endl;
+2 -4
View File
@@ -70,13 +70,13 @@ public:
typedef ThreadQueue<DemodulatorWorkerThreadCommand> DemodulatorThreadWorkerCommandQueue;
typedef ThreadQueue<DemodulatorWorkerThreadResult> DemodulatorThreadWorkerResultQueue;
class DemodulatorWorkerThread {
class DemodulatorWorkerThread : public IOThread {
public:
DemodulatorWorkerThread(DemodulatorThreadWorkerCommandQueue* in, DemodulatorThreadWorkerResultQueue* out);
~DemodulatorWorkerThread();
void threadMain();
void run();
void setCommandQueue(DemodulatorThreadWorkerCommandQueue *tQueue) {
commandQueue = tQueue;
@@ -92,6 +92,4 @@ protected:
DemodulatorThreadWorkerCommandQueue *commandQueue;
DemodulatorThreadWorkerResultQueue *resultQueue;
std::atomic_bool terminated;
};