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

View File

@ -22,7 +22,7 @@
IMPLEMENT_APP(CubicSDR)
CubicSDR::CubicSDR() : appframe(NULL), m_glContext(NULL), frequency(0), offset(0), ppm(0), snap(1), sampleRate(DEFAULT_SAMPLE_RATE), directSamplingMode(0),
sdrThread(NULL), sdrPostThread(NULL), threadCmdQueueSDR(NULL), iqPostDataQueue(NULL), iqVisualQueue(NULL), audioVisualQueue(NULL), t_SDR(NULL), t_PostSDR(NULL) {
sdrThread(NULL), sdrPostThread(NULL), pipeSDRCommand(NULL), pipeSDRIQData(NULL), pipeIQVisualData(NULL), pipeAudioVisualData(NULL), t_SDR(NULL), t_PostSDR(NULL) {
}
@ -52,24 +52,24 @@ bool CubicSDR::OnInit() {
directSamplingMode = 0;
// Visual Data
iqVisualQueue = new DemodulatorThreadInputQueue();
iqVisualQueue->set_max_num_items(1);
pipeIQVisualData = new DemodulatorThreadInputQueue();
pipeIQVisualData->set_max_num_items(1);
audioVisualQueue = new DemodulatorThreadOutputQueue();
audioVisualQueue->set_max_num_items(1);
pipeAudioVisualData = new DemodulatorThreadOutputQueue();
pipeAudioVisualData->set_max_num_items(1);
// I/Q Data
iqPostDataQueue = new SDRThreadIQDataQueue;
threadCmdQueueSDR = new SDRThreadCommandQueue();
pipeSDRIQData = new SDRThreadIQDataQueue;
pipeSDRCommand = new SDRThreadCommandQueue();
sdrThread = new SDRThread();
sdrThread->setInputQueue("SDRCommandQueue",threadCmdQueueSDR);
sdrThread->setOutputQueue("IQDataOutput",iqPostDataQueue);
sdrThread->setInputQueue("SDRCommandQueue",pipeSDRCommand);
sdrThread->setOutputQueue("IQDataOutput",pipeSDRIQData);
sdrPostThread = new SDRPostThread();
sdrPostThread->setNumVisSamples(16384 * 2);
sdrPostThread->setInputQueue("IQDataInput", iqPostDataQueue);
sdrPostThread->setOutputQueue("IQVisualDataOut", iqVisualQueue);
sdrPostThread->setInputQueue("IQDataInput", pipeSDRIQData);
sdrPostThread->setOutputQueue("IQVisualDataOut", pipeIQVisualData);
std::vector<SDRDeviceInfo *>::iterator devs_i;
@ -153,11 +153,11 @@ int CubicSDR::OnExit() {
delete sdrPostThread;
delete t_PostSDR;
delete threadCmdQueueSDR;
delete pipeSDRCommand;
delete iqVisualQueue;
delete audioVisualQueue;
delete iqPostDataQueue;
delete pipeIQVisualData;
delete pipeAudioVisualData;
delete pipeSDRIQData;
delete m_glContext;
@ -203,7 +203,7 @@ void CubicSDR::setFrequency(long long freq) {
frequency = freq;
SDRThreadCommand command(SDRThreadCommand::SDR_THREAD_CMD_TUNE);
command.llong_value = freq;
threadCmdQueueSDR->push(command);
pipeSDRCommand->push(command);
}
long long CubicSDR::getOffset() {
@ -214,7 +214,7 @@ void CubicSDR::setOffset(long long ofs) {
offset = ofs;
SDRThreadCommand command(SDRThreadCommand::SDR_THREAD_CMD_SET_OFFSET);
command.llong_value = ofs;
threadCmdQueueSDR->push(command);
pipeSDRCommand->push(command);
SDRDeviceInfo *dev = (*getDevices())[getDevice()];
config.getDevice(dev->getDeviceId())->setOffset(ofs);
@ -224,7 +224,7 @@ void CubicSDR::setDirectSampling(int mode) {
directSamplingMode = mode;
SDRThreadCommand command(SDRThreadCommand::SDR_THREAD_CMD_SET_DIRECT_SAMPLING);
command.llong_value = mode;
threadCmdQueueSDR->push(command);
pipeSDRCommand->push(command);
SDRDeviceInfo *dev = (*getDevices())[getDevice()];
config.getDevice(dev->getDeviceId())->setDirectSampling(mode);
@ -249,11 +249,11 @@ long long CubicSDR::getFrequency() {
}
DemodulatorThreadOutputQueue* CubicSDR::getAudioVisualQueue() {
return audioVisualQueue;
return pipeAudioVisualData;
}
DemodulatorThreadInputQueue* CubicSDR::getIQVisualQueue() {
return iqVisualQueue;
return pipeIQVisualData;
}
DemodulatorMgr &CubicSDR::getDemodMgr() {
@ -271,7 +271,7 @@ void CubicSDR::setSampleRate(long long rate_in) {
sampleRate = rate_in;
SDRThreadCommand command(SDRThreadCommand::SDR_THREAD_CMD_SET_SAMPLERATE);
command.llong_value = rate_in;
threadCmdQueueSDR->push(command);
pipeSDRCommand->push(command);
setFrequency(frequency);
}
@ -295,7 +295,7 @@ void CubicSDR::setDevice(int deviceId) {
sdrThread->setDeviceId(deviceId);
SDRThreadCommand command(SDRThreadCommand::SDR_THREAD_CMD_SET_DEVICE);
command.llong_value = deviceId;
threadCmdQueueSDR->push(command);
pipeSDRCommand->push(command);
SDRDeviceInfo *dev = (*getDevices())[deviceId];
DeviceConfig *devConfig = config.getDevice(dev->getDeviceId());
@ -326,7 +326,7 @@ void CubicSDR::setPPM(int ppm_in) {
SDRThreadCommand command(SDRThreadCommand::SDR_THREAD_CMD_SET_PPM);
command.llong_value = ppm;
threadCmdQueueSDR->push(command);
pipeSDRCommand->push(command);
SDRDeviceInfo *dev = (*getDevices())[getDevice()];

View File

@ -87,10 +87,10 @@ private:
SDRThread *sdrThread;
SDRPostThread *sdrPostThread;
SDRThreadCommandQueue* threadCmdQueueSDR;
SDRThreadIQDataQueue* iqPostDataQueue;
DemodulatorThreadInputQueue* iqVisualQueue;
DemodulatorThreadOutputQueue* audioVisualQueue;
SDRThreadCommandQueue* pipeSDRCommand;
SDRThreadIQDataQueue* pipeSDRIQData;
DemodulatorThreadInputQueue* pipeIQVisualData;
DemodulatorThreadOutputQueue* pipeAudioVisualData;
std::thread *t_SDR;
std::thread *t_PostSDR;

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;
}

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();

View File

@ -176,7 +176,7 @@ void SDRPostThread::run() {
std::vector<DemodulatorInstance *>::iterator i;
for (i = demodulators.begin(); i != demodulators.end(); i++) {
DemodulatorInstance *demod = *i;
DemodulatorThreadInputQueue *demodQueue = demod->threadQueueDemod;
DemodulatorThreadInputQueue *demodQueue = demod->getIQInputDataPipe();
if (abs(data_in->frequency - demod->getFrequency()) > (wxGetApp().getSampleRate() / 2)) {
if (demod->isActive() && !demod->isFollow() && !demod->isTracking()) {