Cleanup / refactor "pipe" names for clarity

This commit is contained in:
Charles J. Cliffe
2015-07-30 20:36:06 -04:00
parent 10e35002f1
commit c1774ee96a
5 changed files with 69 additions and 61 deletions
+29 -25
View File
@@ -1,7 +1,7 @@
#include "DemodulatorInstance.h"
DemodulatorInstance::DemodulatorInstance() :
threadQueueDemod(NULL), demodulatorThread(NULL), t_PreDemod(NULL), t_Demod(NULL), t_Audio(NULL), currentAudioGain(1.0) {
pipeIQInputData(NULL), demodulatorThread(NULL), t_PreDemod(NULL), t_Demod(NULL), t_Audio(NULL), currentAudioGain(1.0) {
terminated.store(true);
audioTerminated.store(true);
@@ -19,29 +19,29 @@ DemodulatorInstance::DemodulatorInstance() :
label = new std::string("Unnamed");
threadQueueDemod = new DemodulatorThreadInputQueue;
threadQueuePostDemod = new DemodulatorThreadPostInputQueue;
threadQueueCommand = new DemodulatorThreadCommandQueue;
threadQueueNotify = new DemodulatorThreadCommandQueue;
pipeIQInputData = new DemodulatorThreadInputQueue;
pipeIQDemodData = new DemodulatorThreadPostInputQueue;
pipeDemodCommand = new DemodulatorThreadCommandQueue;
pipeDemodNotify = new DemodulatorThreadCommandQueue;
demodulatorPreThread = new DemodulatorPreThread();
demodulatorPreThread->setInputQueue("IQDataInput",threadQueueDemod);
demodulatorPreThread->setOutputQueue("IQDataOutput",threadQueuePostDemod);
demodulatorPreThread->setOutputQueue("NotifyQueue",threadQueueNotify);
demodulatorPreThread->setInputQueue("CommandQueue",threadQueueCommand);
demodulatorPreThread->setInputQueue("IQDataInput",pipeIQInputData);
demodulatorPreThread->setOutputQueue("IQDataOutput",pipeIQDemodData);
demodulatorPreThread->setOutputQueue("NotifyQueue",pipeDemodNotify);
demodulatorPreThread->setInputQueue("CommandQueue",pipeDemodCommand);
audioInputQueue = new AudioThreadInputQueue;
threadQueueControl = new DemodulatorThreadControlCommandQueue;
demodulatorThread = new DemodulatorThread();
demodulatorThread->setInputQueue("IQDataInput",threadQueuePostDemod);
demodulatorThread->setInputQueue("IQDataInput",pipeIQDemodData);
demodulatorThread->setInputQueue("ControlQueue",threadQueueControl);
demodulatorThread->setOutputQueue("NotifyQueue",threadQueueNotify);
demodulatorThread->setOutputQueue("NotifyQueue",pipeDemodNotify);
demodulatorThread->setOutputQueue("AudioDataOutput", audioInputQueue);
audioThread = new AudioThread();
audioThread->setInputQueue("AudioDataInput", audioInputQueue);
audioThread->setOutputQueue("NotifyQueue", threadQueueNotify);
audioThread->setOutputQueue("NotifyQueue", pipeDemodNotify);
currentDemodType = demodulatorThread->getDemodulatorType();
}
@@ -50,10 +50,10 @@ DemodulatorInstance::~DemodulatorInstance() {
delete audioThread;
delete demodulatorThread;
delete demodulatorPreThread;
delete threadQueueDemod;
delete threadQueuePostDemod;
delete threadQueueCommand;
delete threadQueueNotify;
delete pipeIQInputData;
delete pipeIQDemodData;
delete pipeDemodCommand;
delete pipeDemodNotify;
delete threadQueueControl;
delete audioInputQueue;
}
@@ -113,7 +113,7 @@ void DemodulatorInstance::updateLabel(long long freq) {
}
DemodulatorThreadCommandQueue *DemodulatorInstance::getCommandQueue() {
return threadQueueCommand;
return pipeDemodCommand;
}
void DemodulatorInstance::terminate() {
@@ -139,9 +139,9 @@ void DemodulatorInstance::setLabel(std::string labelStr) {
}
bool DemodulatorInstance::isTerminated() {
while (!threadQueueNotify->empty()) {
while (!pipeDemodNotify->empty()) {
DemodulatorThreadCommand cmd;
threadQueueNotify->pop(cmd);
pipeDemodNotify->pop(cmd);
switch (cmd.cmd) {
case DemodulatorThreadCommand::DEMOD_THREAD_CMD_AUDIO_TERMINATED:
@@ -311,13 +311,13 @@ void DemodulatorInstance::setBandwidth(int bw) {
currentBandwidth = bw;
checkBandwidth();
demodulatorPreThread->getParams().bandwidth = currentBandwidth;
} else if (demodulatorPreThread && threadQueueCommand) {
} else if (demodulatorPreThread && pipeDemodCommand) {
DemodulatorThreadCommand command;
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_BANDWIDTH;
currentBandwidth = bw;
checkBandwidth();
command.llong_value = currentBandwidth;
threadQueueCommand->push(command);
pipeDemodCommand->push(command);
}
}
@@ -335,12 +335,12 @@ void DemodulatorInstance::setFrequency(long long freq) {
if (!active) {
currentFrequency = freq;
demodulatorPreThread->getParams().frequency = currentFrequency;
} else if (demodulatorPreThread && threadQueueCommand) {
} else if (demodulatorPreThread && pipeDemodCommand) {
DemodulatorThreadCommand command;
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_FREQUENCY;
currentFrequency = freq;
command.llong_value = freq;
threadQueueCommand->push(command);
pipeDemodCommand->push(command);
}
}
@@ -356,12 +356,12 @@ void DemodulatorInstance::setAudioSampleRate(int sampleRate) {
if (terminated) {
currentAudioSampleRate = sampleRate;
demodulatorPreThread->getParams().audioSampleRate = sampleRate;
} else if (demodulatorPreThread && threadQueueCommand) {
} else if (demodulatorPreThread && pipeDemodCommand) {
DemodulatorThreadCommand command;
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_AUDIO_RATE;
currentAudioSampleRate = sampleRate;
command.llong_value = sampleRate;
threadQueueCommand->push(command);
pipeDemodCommand->push(command);
}
if (currentDemodType == DEMOD_TYPE_RAW) {
setBandwidth(currentAudioSampleRate);
@@ -411,3 +411,7 @@ bool DemodulatorInstance::isTracking() {
void DemodulatorInstance::setTracking(bool tracking) {
this->tracking = tracking;
}
DemodulatorThreadInputQueue *DemodulatorInstance::getIQInputDataPipe() {
return pipeIQInputData;
}
+12 -8
View File
@@ -10,14 +10,6 @@
class DemodulatorInstance {
public:
DemodulatorThreadInputQueue* threadQueueDemod;
DemodulatorThreadPostInputQueue* threadQueuePostDemod;
DemodulatorThreadCommandQueue* threadQueueCommand;
DemodulatorThreadCommandQueue* threadQueueNotify;
DemodulatorPreThread *demodulatorPreThread;
DemodulatorThread *demodulatorThread;
DemodulatorThreadControlCommandQueue *threadQueueControl;
#ifdef __APPLE__
pthread_t t_PreDemod;
pthread_t t_Demod;
@@ -82,6 +74,18 @@ public:
bool isTracking();
void setTracking(bool tracking);
DemodulatorThreadInputQueue *getIQInputDataPipe();
protected:
DemodulatorThreadInputQueue* pipeIQInputData;
DemodulatorThreadPostInputQueue* pipeIQDemodData;
DemodulatorThreadCommandQueue* pipeDemodCommand;
DemodulatorThreadCommandQueue* pipeDemodNotify;
DemodulatorPreThread *demodulatorPreThread;
DemodulatorThread *demodulatorThread;
DemodulatorThreadControlCommandQueue *threadQueueControl;
private:
void checkBandwidth();