aboutsummaryrefslogtreecommitdiffstats
path: root/src/FIRFilter.h
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-03-17 14:14:31 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-03-17 14:14:31 +0100
commit937473ba892e1965be1614f95b32a22e3eb8ba4e (patch)
tree0ea627b3a7c828494d35ebd797d3fe0a5794bd87 /src/FIRFilter.h
parent987a31954ea574e04c2e79fe3765448c1b607e49 (diff)
downloaddabmod-937473ba892e1965be1614f95b32a22e3eb8ba4e.tar.gz
dabmod-937473ba892e1965be1614f95b32a22e3eb8ba4e.tar.bz2
dabmod-937473ba892e1965be1614f95b32a22e3eb8ba4e.zip
Simplify FIRFilter and make it use PipelinedModCodec
Diffstat (limited to 'src/FIRFilter.h')
-rw-r--r--src/FIRFilter.h69
1 files changed, 10 insertions, 59 deletions
diff --git a/src/FIRFilter.h b/src/FIRFilter.h
index 209d79d..1fe0004 100644
--- a/src/FIRFilter.h
+++ b/src/FIRFilter.h
@@ -2,8 +2,10 @@
Copyright (C) 2007, 2008, 2009, 2010, 2011 Her Majesty the Queen in
Right of Canada (Communications Research Center Canada)
- Written by
- 2012, Matthias P. Braendli, matthias.braendli@mpb.li
+ Copyright (C) 2017
+ Matthias P. Braendli, matthias.braendli@mpb.li
+
+ http://opendigitalradio.org
*/
/*
This file is part of ODR-DabMod.
@@ -28,7 +30,6 @@
# include <config.h>
#endif
-#include <boost/thread.hpp>
#include "RemoteControl.h"
#include "ModPlugin.h"
@@ -37,6 +38,7 @@
#include <sys/types.h>
#include <complex>
+#include <thread>
#include <vector>
#include <time.h>
#include <cstdio>
@@ -47,62 +49,11 @@
typedef std::complex<float> complexf;
-struct FIRFilterWorkerData {
- /* Thread-safe queues to give data to and get data from
- * the worker
- */
- ThreadsafeQueue<std::shared_ptr<Buffer> > input_queue;
- ThreadsafeQueue<std::shared_ptr<Buffer> > output_queue;
-
- /* Remote-control can change the taps while the filter
- * runs. This lock makes sure nothing bad happens when
- * the taps are being modified
- */
- mutable boost::mutex taps_mutex;
- std::vector<float> taps;
-};
-
-class FIRFilterWorker {
- public:
- FIRFilterWorker () {
- running = false;
- calculationTime = 0;
- }
-
- ~FIRFilterWorker() {
- PDEBUG("~FIRFilterWorker: Total elapsed thread time filtering: %zu\n", calculationTime);
- }
-
- void start(struct FIRFilterWorkerData *firworkerdata) {
- running = true;
- fir_thread = boost::thread(&FIRFilterWorker::process, this, firworkerdata);
- }
-
- void stop() {
- running = false;
- fir_thread.interrupt();
- fir_thread.join();
- }
-
- void process(struct FIRFilterWorkerData *fwd);
-
-
- private:
- time_t calculationTime;
- bool running;
- boost::thread fir_thread;
-};
-
-
-class FIRFilter : public ModCodec, public RemoteControllable
+class FIRFilter : public PipelinedModCodec, public RemoteControllable
{
public:
FIRFilter(const std::string& taps_file);
- virtual ~FIRFilter();
- FIRFilter(const FIRFilter&);
- FIRFilter& operator=(const FIRFilter&);
- int process(Buffer* const dataIn, Buffer* dataOut);
const char* name() { return "FIRFilter"; }
/******* REMOTE CONTROL ********/
@@ -114,12 +65,12 @@ public:
protected:
+ int internal_process(Buffer* const dataIn, Buffer* dataOut);
void load_filter_taps(const std::string &tapsFile);
- std::string myTapsFile;
+ std::string m_taps_file;
- FIRFilterWorker worker;
- int number_of_runs;
- struct FIRFilterWorkerData firwd;
+ mutable std::mutex m_taps_mutex;
+ std::vector<float> m_taps;
};