Cleanup: data, visual processor threads

This commit is contained in:
Charles J. Cliffe 2021-04-04 22:18:19 -04:00
parent 0b9bcc5a46
commit e9a6fc089c
11 changed files with 27 additions and 35 deletions

View File

@ -21,7 +21,7 @@ void FFTDataDistributor::setLinesPerSecond(unsigned int lines) {
this->linesPerSecond = lines;
}
unsigned int FFTDataDistributor::getLinesPerSecond() {
unsigned int FFTDataDistributor::getLinesPerSecond() const {
return this->linesPerSecond;
}

View File

@ -14,12 +14,12 @@ public:
FFTDataDistributor();
void setFFTSize(unsigned int size);
void setLinesPerSecond(unsigned int lines);
unsigned int getLinesPerSecond();
unsigned int getLinesPerSecond() const;
protected:
virtual void process();
void process() override;
DemodulatorThreadIQData inputBuffer, tempBuffer;
DemodulatorThreadIQData inputBuffer;
ReBuffer<DemodulatorThreadIQData> outputBuffers;
std::atomic<unsigned int> fftSize;

View File

@ -2,16 +2,13 @@
// SPDX-License-Identifier: GPL-2.0+
#include "FFTVisualDataThread.h"
#include "CubicSDR.h"
FFTVisualDataThread::FFTVisualDataThread() {
linesPerSecond.store(DEFAULT_WATERFALL_LPS);
lpsChanged.store(true);
}
FFTVisualDataThread::~FFTVisualDataThread() {
}
FFTVisualDataThread::~FFTVisualDataThread() = default;
void FFTVisualDataThread::setLinesPerSecond(int lps) {
linesPerSecond.store(lps);

View File

@ -10,15 +10,15 @@
class FFTVisualDataThread : public IOThread {
public:
FFTVisualDataThread();
~FFTVisualDataThread();
~FFTVisualDataThread() override;
void setLinesPerSecond(int lps);
int getLinesPerSecond();
SpectrumVisualProcessor *getProcessor();
virtual void run();
void run() override;
virtual void terminate();
void terminate() override;
protected:
FFTDataDistributor fftDistrib;

View File

@ -3,7 +3,6 @@
#include "ScopeVisualProcessor.h"
#include <cstring>
#include <string>
ScopeVisualProcessor::ScopeVisualProcessor(): outputBuffers("ScopeVisualProcessorBuffers") {
scopeEnabled.store(true);

View File

@ -19,9 +19,7 @@ public:
int fft_size;
double fft_floor, fft_ceil;
virtual ~ScopeRenderData() {
}
virtual ~ScopeRenderData() = default;
};
typedef std::shared_ptr<ScopeRenderData> ScopeRenderDataPtr;
@ -33,12 +31,12 @@ typedef std::shared_ptr<ScopeRenderDataQueue> ScopeRenderDataQueuePtr;
class ScopeVisualProcessor : public VisualProcessor<AudioThreadInput, ScopeRenderData> {
public:
ScopeVisualProcessor();
~ScopeVisualProcessor();
~ScopeVisualProcessor() override;
void setup(int fftSize_in);
void setScopeEnabled(bool scopeEnable);
void setSpectrumEnabled(bool spectrumEnable);
protected:
virtual void process();
void process() override;
ReBuffer<ScopeRenderData> outputBuffers;
std::atomic_bool scopeEnabled;

View File

@ -2,14 +2,10 @@
// SPDX-License-Identifier: GPL-2.0+
#include "SpectrumVisualDataThread.h"
#include "CubicSDR.h"
SpectrumVisualDataThread::SpectrumVisualDataThread() {
}
SpectrumVisualDataThread::SpectrumVisualDataThread() = default;
SpectrumVisualDataThread::~SpectrumVisualDataThread() {
}
SpectrumVisualDataThread::~SpectrumVisualDataThread() = default;
SpectrumVisualProcessor *SpectrumVisualDataThread::getProcessor() {
return &sproc;

View File

@ -9,12 +9,12 @@
class SpectrumVisualDataThread : public IOThread {
public:
SpectrumVisualDataThread();
~SpectrumVisualDataThread();
~SpectrumVisualDataThread() override;
SpectrumVisualProcessor *getProcessor();
virtual void run();
void run() override;
virtual void terminate();
void terminate() override;
protected:
SpectrumVisualProcessor sproc;

View File

@ -201,11 +201,11 @@ unsigned int SpectrumVisualProcessor::getFFTSize() {
}
void SpectrumVisualProcessor::setHideDC(bool hideDC) {
void SpectrumVisualProcessor::setHideDC(bool hideDC_in) {
std::lock_guard < std::mutex > busy_lock(busy_run);
this->hideDC = hideDC;
hideDC = hideDC_in;
}
@ -274,7 +274,7 @@ void SpectrumVisualProcessor::process() {
std::vector<liquid_float_complex> *data = &iqData->data;
if (data && data->size()) {
if (data && !data->empty()) {
unsigned int num_written;
long resampleBw = iqData->sampleRate;
bool newResampler = false;

View File

@ -19,7 +19,7 @@ public:
long long centerFreq;
int bandwidth;
virtual ~SpectrumVisualData() {};
virtual ~SpectrumVisualData() = default;;
};
typedef std::shared_ptr<SpectrumVisualData> SpectrumVisualDataPtr;
@ -29,7 +29,7 @@ typedef std::shared_ptr<SpectrumVisualDataQueue> SpectrumVisualDataQueuePtr;
class SpectrumVisualProcessor : public VisualProcessor<DemodulatorThreadIQData, SpectrumVisualData> {
public:
SpectrumVisualProcessor();
~SpectrumVisualProcessor();
~SpectrumVisualProcessor() override;
bool isView();
void setView(bool bView);
@ -52,13 +52,13 @@ public:
void setup(unsigned int fftSize);
void setFFTSize(unsigned int fftSize);
unsigned int getFFTSize();
void setHideDC(bool hideDC);
void setHideDC(bool hideDC_in);
void setScaleFactor(float sf);
float getScaleFactor();
protected:
virtual void process();
void process() override;
ReBuffer<SpectrumVisualData> outputBuffers;

View File

@ -24,8 +24,7 @@ public:
typedef std::shared_ptr<VisualInputQueueType> VisualInputQueueTypePtr;
typedef std::shared_ptr<VisualOutputQueueType> VisualOutputQueueTypePtr;
virtual ~VisualProcessor() {
}
virtual ~VisualProcessor();
bool isInputEmpty() {
std::lock_guard < std::mutex > busy_lock(busy_update);
@ -155,6 +154,9 @@ protected:
std::mutex busy_update;
};
template<typename InputDataType, typename OutputDataType>
VisualProcessor<InputDataType, OutputDataType>::~VisualProcessor() = default;
//Specialization much like VisualDataReDistributor, except
//the input (pointer) is directly re-dispatched
//to outputs, so that all output indeed SHARE the same instance.