From c31496c68f2bbbab71c15635a2053f52e7a0ecf8 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 17 Mar 2017 10:57:08 +0100 Subject: Add threaded ModCodec and use it for GainControl --- src/ModPlugin.h | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'src/ModPlugin.h') 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 #include +#include +#include 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 > m_input_queue; + ThreadsafeQueue > m_output_queue; + + std::atomic m_running; + size_t m_number_of_runs; + std::thread m_thread; +}; + + /* Muxes are N-input 1-output flowgraph plugins */ class ModMux : public ModPlugin { -- cgit v1.2.3