aboutsummaryrefslogtreecommitdiffstats
path: root/src/ModPlugin.h
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-03-17 10:57:08 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-03-17 10:57:08 +0100
commitc31496c68f2bbbab71c15635a2053f52e7a0ecf8 (patch)
tree4067427b706aa72fc0b4a779647852889f0b5b59 /src/ModPlugin.h
parent0a88998e2e183ac62aa3858a17a28ce0303a9780 (diff)
downloaddabmod-c31496c68f2bbbab71c15635a2053f52e7a0ecf8.tar.gz
dabmod-c31496c68f2bbbab71c15635a2053f52e7a0ecf8.tar.bz2
dabmod-c31496c68f2bbbab71c15635a2053f52e7a0ecf8.zip
Add threaded ModCodec and use it for GainControl
Diffstat (limited to 'src/ModPlugin.h')
-rw-r--r--src/ModPlugin.h31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/ModPlugin.h b/src/ModPlugin.h
index bdc3843..edb7d2d 100644
--- a/src/ModPlugin.h
+++ b/src/ModPlugin.h
@@ -2,7 +2,7 @@
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Her Majesty
the Queen in Right of Canada (Communications Research Center Canada)
- Copyright (C) 2016
+ Copyright (C) 2017
Matthias P. Braendli, matthias.braendli@mpb.li
http://opendigitalradio.org
@@ -32,9 +32,12 @@
#include "Buffer.h"
+#include "ThreadsafeQueue.h"
#include <sys/types.h>
#include <vector>
+#include <memory>
+#include <thread>
class ModPlugin
{
@@ -65,6 +68,32 @@ public:
virtual int process(Buffer* const dataIn, Buffer* dataOut) = 0;
};
+class PipelinedModCodec : public ModCodec
+{
+public:
+ PipelinedModCodec();
+ PipelinedModCodec(const PipelinedModCodec&) = delete;
+ PipelinedModCodec& operator=(const PipelinedModCodec&) = delete;
+ PipelinedModCodec(PipelinedModCodec&&) = delete;
+ PipelinedModCodec& operator=(PipelinedModCodec&&) = delete;
+ ~PipelinedModCodec();
+
+ virtual int process(Buffer* const dataIn, Buffer* dataOut) final;
+ virtual const char* name() = 0;
+
+protected:
+ void process_thread(void);
+ virtual int internal_process(Buffer* const dataIn, Buffer* dataOut) = 0;
+
+ ThreadsafeQueue<std::shared_ptr<Buffer> > m_input_queue;
+ ThreadsafeQueue<std::shared_ptr<Buffer> > m_output_queue;
+
+ std::atomic<bool> m_running;
+ size_t m_number_of_runs;
+ std::thread m_thread;
+};
+
+
/* Muxes are N-input 1-output flowgraph plugins */
class ModMux : public ModPlugin
{