diff options
Diffstat (limited to 'src/ModPlugin.h')
-rw-r--r-- | src/ModPlugin.h | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/src/ModPlugin.h b/src/ModPlugin.h index bdc3843..d3aa780 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,13 @@ #include "Buffer.h" +#include "ThreadsafeQueue.h" #include <sys/types.h> #include <vector> +#include <memory> +#include <thread> +#include <atomic> class ModPlugin { @@ -65,6 +69,37 @@ 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: + // Once the instance implementing PipelinedModCodec has been constructed, + // it must call start_pipeline_thread() + void start_pipeline_thread(void); + virtual int internal_process(Buffer* const dataIn, Buffer* dataOut) = 0; + +private: + size_t m_number_of_runs; + + ThreadsafeQueue<std::shared_ptr<Buffer> > m_input_queue; + ThreadsafeQueue<std::shared_ptr<Buffer> > m_output_queue; + + std::atomic<bool> m_running; + std::thread m_thread; + void process_thread(void); +}; + + /* Muxes are N-input 1-output flowgraph plugins */ class ModMux : public ModPlugin { |