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

View File

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

View File

@ -1,7 +1,7 @@
#include "DemodulatorInstance.h" #include "DemodulatorInstance.h"
DemodulatorInstance::DemodulatorInstance() : 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); terminated.store(true);
audioTerminated.store(true); audioTerminated.store(true);
@ -19,29 +19,29 @@ DemodulatorInstance::DemodulatorInstance() :
label = new std::string("Unnamed"); label = new std::string("Unnamed");
threadQueueDemod = new DemodulatorThreadInputQueue; pipeIQInputData = new DemodulatorThreadInputQueue;
threadQueuePostDemod = new DemodulatorThreadPostInputQueue; pipeIQDemodData = new DemodulatorThreadPostInputQueue;
threadQueueCommand = new DemodulatorThreadCommandQueue; pipeDemodCommand = new DemodulatorThreadCommandQueue;
threadQueueNotify = new DemodulatorThreadCommandQueue; pipeDemodNotify = new DemodulatorThreadCommandQueue;
demodulatorPreThread = new DemodulatorPreThread(); demodulatorPreThread = new DemodulatorPreThread();
demodulatorPreThread->setInputQueue("IQDataInput",threadQueueDemod); demodulatorPreThread->setInputQueue("IQDataInput",pipeIQInputData);
demodulatorPreThread->setOutputQueue("IQDataOutput",threadQueuePostDemod); demodulatorPreThread->setOutputQueue("IQDataOutput",pipeIQDemodData);
demodulatorPreThread->setOutputQueue("NotifyQueue",threadQueueNotify); demodulatorPreThread->setOutputQueue("NotifyQueue",pipeDemodNotify);
demodulatorPreThread->setInputQueue("CommandQueue",threadQueueCommand); demodulatorPreThread->setInputQueue("CommandQueue",pipeDemodCommand);
audioInputQueue = new AudioThreadInputQueue; audioInputQueue = new AudioThreadInputQueue;
threadQueueControl = new DemodulatorThreadControlCommandQueue; threadQueueControl = new DemodulatorThreadControlCommandQueue;
demodulatorThread = new DemodulatorThread(); demodulatorThread = new DemodulatorThread();
demodulatorThread->setInputQueue("IQDataInput",threadQueuePostDemod); demodulatorThread->setInputQueue("IQDataInput",pipeIQDemodData);
demodulatorThread->setInputQueue("ControlQueue",threadQueueControl); demodulatorThread->setInputQueue("ControlQueue",threadQueueControl);
demodulatorThread->setOutputQueue("NotifyQueue",threadQueueNotify); demodulatorThread->setOutputQueue("NotifyQueue",pipeDemodNotify);
demodulatorThread->setOutputQueue("AudioDataOutput", audioInputQueue); demodulatorThread->setOutputQueue("AudioDataOutput", audioInputQueue);
audioThread = new AudioThread(); audioThread = new AudioThread();
audioThread->setInputQueue("AudioDataInput", audioInputQueue); audioThread->setInputQueue("AudioDataInput", audioInputQueue);
audioThread->setOutputQueue("NotifyQueue", threadQueueNotify); audioThread->setOutputQueue("NotifyQueue", pipeDemodNotify);
currentDemodType = demodulatorThread->getDemodulatorType(); currentDemodType = demodulatorThread->getDemodulatorType();
} }
@ -50,10 +50,10 @@ DemodulatorInstance::~DemodulatorInstance() {
delete audioThread; delete audioThread;
delete demodulatorThread; delete demodulatorThread;
delete demodulatorPreThread; delete demodulatorPreThread;
delete threadQueueDemod; delete pipeIQInputData;
delete threadQueuePostDemod; delete pipeIQDemodData;
delete threadQueueCommand; delete pipeDemodCommand;
delete threadQueueNotify; delete pipeDemodNotify;
delete threadQueueControl; delete threadQueueControl;
delete audioInputQueue; delete audioInputQueue;
} }
@ -113,7 +113,7 @@ void DemodulatorInstance::updateLabel(long long freq) {
} }
DemodulatorThreadCommandQueue *DemodulatorInstance::getCommandQueue() { DemodulatorThreadCommandQueue *DemodulatorInstance::getCommandQueue() {
return threadQueueCommand; return pipeDemodCommand;
} }
void DemodulatorInstance::terminate() { void DemodulatorInstance::terminate() {
@ -139,9 +139,9 @@ void DemodulatorInstance::setLabel(std::string labelStr) {
} }
bool DemodulatorInstance::isTerminated() { bool DemodulatorInstance::isTerminated() {
while (!threadQueueNotify->empty()) { while (!pipeDemodNotify->empty()) {
DemodulatorThreadCommand cmd; DemodulatorThreadCommand cmd;
threadQueueNotify->pop(cmd); pipeDemodNotify->pop(cmd);
switch (cmd.cmd) { switch (cmd.cmd) {
case DemodulatorThreadCommand::DEMOD_THREAD_CMD_AUDIO_TERMINATED: case DemodulatorThreadCommand::DEMOD_THREAD_CMD_AUDIO_TERMINATED:
@ -311,13 +311,13 @@ void DemodulatorInstance::setBandwidth(int bw) {
currentBandwidth = bw; currentBandwidth = bw;
checkBandwidth(); checkBandwidth();
demodulatorPreThread->getParams().bandwidth = currentBandwidth; demodulatorPreThread->getParams().bandwidth = currentBandwidth;
} else if (demodulatorPreThread && threadQueueCommand) { } else if (demodulatorPreThread && pipeDemodCommand) {
DemodulatorThreadCommand command; DemodulatorThreadCommand command;
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_BANDWIDTH; command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_BANDWIDTH;
currentBandwidth = bw; currentBandwidth = bw;
checkBandwidth(); checkBandwidth();
command.llong_value = currentBandwidth; command.llong_value = currentBandwidth;
threadQueueCommand->push(command); pipeDemodCommand->push(command);
} }
} }
@ -335,12 +335,12 @@ void DemodulatorInstance::setFrequency(long long freq) {
if (!active) { if (!active) {
currentFrequency = freq; currentFrequency = freq;
demodulatorPreThread->getParams().frequency = currentFrequency; demodulatorPreThread->getParams().frequency = currentFrequency;
} else if (demodulatorPreThread && threadQueueCommand) { } else if (demodulatorPreThread && pipeDemodCommand) {
DemodulatorThreadCommand command; DemodulatorThreadCommand command;
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_FREQUENCY; command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_FREQUENCY;
currentFrequency = freq; currentFrequency = freq;
command.llong_value = freq; command.llong_value = freq;
threadQueueCommand->push(command); pipeDemodCommand->push(command);
} }
} }
@ -356,12 +356,12 @@ void DemodulatorInstance::setAudioSampleRate(int sampleRate) {
if (terminated) { if (terminated) {
currentAudioSampleRate = sampleRate; currentAudioSampleRate = sampleRate;
demodulatorPreThread->getParams().audioSampleRate = sampleRate; demodulatorPreThread->getParams().audioSampleRate = sampleRate;
} else if (demodulatorPreThread && threadQueueCommand) { } else if (demodulatorPreThread && pipeDemodCommand) {
DemodulatorThreadCommand command; DemodulatorThreadCommand command;
command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_AUDIO_RATE; command.cmd = DemodulatorThreadCommand::DEMOD_THREAD_CMD_SET_AUDIO_RATE;
currentAudioSampleRate = sampleRate; currentAudioSampleRate = sampleRate;
command.llong_value = sampleRate; command.llong_value = sampleRate;
threadQueueCommand->push(command); pipeDemodCommand->push(command);
} }
if (currentDemodType == DEMOD_TYPE_RAW) { if (currentDemodType == DEMOD_TYPE_RAW) {
setBandwidth(currentAudioSampleRate); setBandwidth(currentAudioSampleRate);
@ -411,3 +411,7 @@ bool DemodulatorInstance::isTracking() {
void DemodulatorInstance::setTracking(bool tracking) { void DemodulatorInstance::setTracking(bool tracking) {
this->tracking = tracking; this->tracking = tracking;
} }
DemodulatorThreadInputQueue *DemodulatorInstance::getIQInputDataPipe() {
return pipeIQInputData;
}

View File

@ -10,14 +10,6 @@
class DemodulatorInstance { class DemodulatorInstance {
public: public:
DemodulatorThreadInputQueue* threadQueueDemod;
DemodulatorThreadPostInputQueue* threadQueuePostDemod;
DemodulatorThreadCommandQueue* threadQueueCommand;
DemodulatorThreadCommandQueue* threadQueueNotify;
DemodulatorPreThread *demodulatorPreThread;
DemodulatorThread *demodulatorThread;
DemodulatorThreadControlCommandQueue *threadQueueControl;
#ifdef __APPLE__ #ifdef __APPLE__
pthread_t t_PreDemod; pthread_t t_PreDemod;
pthread_t t_Demod; pthread_t t_Demod;
@ -82,6 +74,18 @@ public:
bool isTracking(); bool isTracking();
void setTracking(bool tracking); void setTracking(bool tracking);
DemodulatorThreadInputQueue *getIQInputDataPipe();
protected:
DemodulatorThreadInputQueue* pipeIQInputData;
DemodulatorThreadPostInputQueue* pipeIQDemodData;
DemodulatorThreadCommandQueue* pipeDemodCommand;
DemodulatorThreadCommandQueue* pipeDemodNotify;
DemodulatorPreThread *demodulatorPreThread;
DemodulatorThread *demodulatorThread;
DemodulatorThreadControlCommandQueue *threadQueueControl;
private: private:
void checkBandwidth(); void checkBandwidth();

View File

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