mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2024-12-23 19:15:40 -05:00
DemodulatorPreThread convert to IOThread named queues
This commit is contained in:
parent
0d66c92f30
commit
d53aabf73a
@ -10,6 +10,7 @@ IOThread::~IOThread() {
|
||||
|
||||
#ifdef __APPLE__
|
||||
void *IOThread::threadMain() {
|
||||
terminated.store(false);
|
||||
run();
|
||||
return this;
|
||||
};
|
||||
@ -19,6 +20,7 @@ void *IOThread::pthread_helper(void *context) {
|
||||
};
|
||||
#else
|
||||
void IOThread::threadMain() {
|
||||
terminated.store(false);
|
||||
run();
|
||||
};
|
||||
#endif
|
||||
|
@ -71,7 +71,7 @@ private:
|
||||
class IOThread {
|
||||
public:
|
||||
IOThread();
|
||||
~IOThread();
|
||||
virtual ~IOThread();
|
||||
|
||||
static void *pthread_helper(void *context);
|
||||
|
||||
|
@ -25,8 +25,13 @@ DemodulatorInstance::DemodulatorInstance() :
|
||||
threadQueueNotify = new DemodulatorThreadCommandQueue;
|
||||
threadQueueControl = new DemodulatorThreadControlCommandQueue;
|
||||
|
||||
demodulatorPreThread = new DemodulatorPreThread(threadQueueDemod, threadQueuePostDemod, threadQueueControl, threadQueueNotify);
|
||||
demodulatorPreThread->setCommandQueue(threadQueueCommand);
|
||||
demodulatorPreThread = new DemodulatorPreThread();
|
||||
demodulatorPreThread->setInputQueue("IQDataInput",threadQueueDemod);
|
||||
demodulatorPreThread->setOutputQueue("IQDataOut",threadQueuePostDemod);
|
||||
demodulatorPreThread->setInputQueue("ControlQueue",threadQueueControl);
|
||||
demodulatorPreThread->setOutputQueue("NotifyQueue",threadQueueNotify);
|
||||
demodulatorPreThread->setInputQueue("CommandQueue",threadQueueCommand);
|
||||
|
||||
demodulatorThread = new DemodulatorThread(threadQueuePostDemod, threadQueueControl, threadQueueNotify);
|
||||
|
||||
audioInputQueue = new AudioThreadInputQueue;
|
||||
|
@ -8,11 +8,7 @@
|
||||
#include "DemodulatorPreThread.h"
|
||||
#include "CubicSDR.h"
|
||||
|
||||
DemodulatorPreThread::DemodulatorPreThread(DemodulatorThreadInputQueue* iqInputQueue, DemodulatorThreadPostInputQueue* iqOutputQueue,
|
||||
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) {
|
||||
DemodulatorPreThread::DemodulatorPreThread() : IOThread(), iqResampler(NULL), iqResampleRatio(1), audioResampler(NULL), stereoResampler(NULL), audioResampleRatio(1), firStereoLeft(NULL), firStereoRight(NULL), iirStereoPilot(NULL) {
|
||||
initialized.store(false);
|
||||
|
||||
freqShifter = nco_crcf_create(LIQUID_VCO);
|
||||
@ -21,8 +17,6 @@ DemodulatorPreThread::DemodulatorPreThread(DemodulatorThreadInputQueue* iqInputQ
|
||||
workerQueue = new DemodulatorThreadWorkerCommandQueue;
|
||||
workerResults = new DemodulatorThreadWorkerResultQueue;
|
||||
workerThread = new DemodulatorWorkerThread(workerQueue, workerResults);
|
||||
|
||||
t_Worker = new std::thread(&DemodulatorWorkerThread::threadMain, workerThread);
|
||||
}
|
||||
|
||||
void DemodulatorPreThread::initialize() {
|
||||
@ -93,8 +87,16 @@ void DemodulatorPreThread::run() {
|
||||
|
||||
std::cout << "Demodulator preprocessor thread started.." << std::endl;
|
||||
|
||||
t_Worker = new std::thread(&DemodulatorWorkerThread::threadMain, workerThread);
|
||||
|
||||
ReBuffer<DemodulatorThreadPostIQData> buffers;
|
||||
|
||||
DemodulatorThreadInputQueue* iqInputQueue = (DemodulatorThreadInputQueue*)getInputQueue("IQDataInput");
|
||||
DemodulatorThreadPostInputQueue* iqOutputQueue = (DemodulatorThreadPostInputQueue*)getOutputQueue("IQDataOut");
|
||||
DemodulatorThreadControlCommandQueue *threadQueueControl = (DemodulatorThreadControlCommandQueue *)getInputQueue("ControlQueue");
|
||||
DemodulatorThreadCommandQueue* threadQueueNotify = (DemodulatorThreadCommandQueue*)getOutputQueue("NotifyQueue");
|
||||
DemodulatorThreadCommandQueue* commandQueue = ( DemodulatorThreadCommandQueue*)getInputQueue("CommandQueue");
|
||||
|
||||
std::vector<liquid_float_complex> in_buf_data;
|
||||
std::vector<liquid_float_complex> out_buf_data;
|
||||
// liquid_float_complex carrySample; // Keep the stream count even to simplify some demod operations
|
||||
@ -307,7 +309,13 @@ void DemodulatorPreThread::run() {
|
||||
}
|
||||
|
||||
buffers.purge();
|
||||
|
||||
|
||||
DemodulatorThreadIQData *inp = new DemodulatorThreadIQData; // push dummy to nudge queue
|
||||
iqInputQueue->push(inp);
|
||||
workerThread->terminate();
|
||||
t_Worker->detach();
|
||||
delete t_Worker;
|
||||
|
||||
DemodulatorThreadCommand tCmd(DemodulatorThreadCommand::DEMOD_THREAD_CMD_DEMOD_PREPROCESS_TERMINATED);
|
||||
tCmd.context = this;
|
||||
threadQueueNotify->push(tCmd);
|
||||
@ -316,9 +324,4 @@ void DemodulatorPreThread::run() {
|
||||
|
||||
void DemodulatorPreThread::terminate() {
|
||||
terminated = true;
|
||||
DemodulatorThreadIQData *inp = new DemodulatorThreadIQData; // push dummy to nudge queue
|
||||
iqInputQueue->push(inp);
|
||||
workerThread->terminate();
|
||||
t_Worker->detach();
|
||||
delete t_Worker;
|
||||
}
|
||||
|
@ -10,20 +10,11 @@
|
||||
class DemodulatorPreThread : public IOThread {
|
||||
public:
|
||||
|
||||
DemodulatorPreThread(DemodulatorThreadInputQueue* iqInputQueue, DemodulatorThreadPostInputQueue* iqOutputQueue,
|
||||
DemodulatorThreadControlCommandQueue *threadQueueControl, DemodulatorThreadCommandQueue* threadQueueNotify);
|
||||
DemodulatorPreThread();
|
||||
~DemodulatorPreThread();
|
||||
|
||||
void run();
|
||||
|
||||
void setCommandQueue(DemodulatorThreadCommandQueue *tQueue) {
|
||||
commandQueue = tQueue;
|
||||
}
|
||||
|
||||
void setDemodulatorControlQueue(DemodulatorThreadControlCommandQueue *tQueue) {
|
||||
threadQueueControl = tQueue;
|
||||
}
|
||||
|
||||
DemodulatorThreadParameters &getParams() {
|
||||
return params;
|
||||
}
|
||||
@ -42,10 +33,6 @@ public:
|
||||
#endif
|
||||
|
||||
protected:
|
||||
DemodulatorThreadInputQueue* iqInputQueue;
|
||||
DemodulatorThreadPostInputQueue* iqOutputQueue;
|
||||
DemodulatorThreadCommandQueue* commandQueue;
|
||||
|
||||
msresamp_crcf iqResampler;
|
||||
double iqResampleRatio;
|
||||
std::vector<liquid_float_complex> resampledData;
|
||||
@ -71,6 +58,4 @@ protected:
|
||||
|
||||
DemodulatorThreadWorkerCommandQueue *workerQueue;
|
||||
DemodulatorThreadWorkerResultQueue *workerResults;
|
||||
DemodulatorThreadCommandQueue* threadQueueNotify;
|
||||
DemodulatorThreadControlCommandQueue *threadQueueControl;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user