mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-07-09 10:35:21 +02:00
DSP performance upgrades + bugfix
This commit is contained in:
@ -11,9 +11,17 @@
|
||||
#define FL_M_PI 3.1415926535f
|
||||
|
||||
namespace dsp {
|
||||
|
||||
class generic_unnamed_block {
|
||||
public:
|
||||
virtual void start() {}
|
||||
virtual void stop() {}
|
||||
virtual int calcOutSize(int inSize) { return inSize; }
|
||||
virtual int run() { return -1; }
|
||||
};
|
||||
|
||||
template <class BLOCK>
|
||||
class generic_block {
|
||||
class generic_block : public generic_unnamed_block {
|
||||
public:
|
||||
virtual void init() {}
|
||||
|
||||
@ -125,4 +133,79 @@ namespace dsp {
|
||||
std::mutex ctrlMtx;
|
||||
|
||||
};
|
||||
|
||||
template <class BLOCK>
|
||||
class generic_hier_block {
|
||||
public:
|
||||
virtual void init() {}
|
||||
|
||||
virtual ~generic_hier_block() {
|
||||
stop();
|
||||
}
|
||||
|
||||
virtual void start() {
|
||||
std::lock_guard<std::mutex> lck(ctrlMtx);
|
||||
if (running) {
|
||||
return;
|
||||
}
|
||||
running = true;
|
||||
doStart();
|
||||
}
|
||||
|
||||
virtual void stop() {
|
||||
std::lock_guard<std::mutex> lck(ctrlMtx);
|
||||
if (!running) {
|
||||
return;
|
||||
}
|
||||
doStop();
|
||||
running = false;
|
||||
}
|
||||
|
||||
virtual int calcOutSize(int inSize) { return inSize; }
|
||||
|
||||
friend BLOCK;
|
||||
|
||||
private:
|
||||
void registerBlock(generic_unnamed_block* block) {
|
||||
blocks.push_back(block);
|
||||
}
|
||||
|
||||
void unregisterBlock(generic_unnamed_block* block) {
|
||||
blocks.erase(std::remove(blocks.begin(), blocks.end(), block), blocks.end());
|
||||
}
|
||||
|
||||
virtual void doStart() {
|
||||
for (auto& block : blocks) {
|
||||
block->start();
|
||||
}
|
||||
}
|
||||
|
||||
virtual void doStop() {
|
||||
for (auto& block : blocks) {
|
||||
block->stop();
|
||||
}
|
||||
}
|
||||
|
||||
void tempStart() {
|
||||
if (tempStopped) {
|
||||
doStart();
|
||||
tempStopped = false;
|
||||
}
|
||||
}
|
||||
|
||||
void tempStop() {
|
||||
if (running && !tempStopped) {
|
||||
doStop();
|
||||
tempStopped = true;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<generic_unnamed_block*> blocks;
|
||||
bool tempStopped = false;
|
||||
bool running = false;
|
||||
|
||||
protected:
|
||||
std::mutex ctrlMtx;
|
||||
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user