From e3de2f4092d1df941d0e5117c8c6533612c52bbc Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 3 Nov 2017 11:08:46 +0100 Subject: Replace flowgraph setup if chain by a loop --- src/DabModulator.cpp | 56 +++++++++++++++++++--------------------------------- 1 file changed, 20 insertions(+), 36 deletions(-) diff --git a/src/DabModulator.cpp b/src/DabModulator.cpp index 0914469..2bd33b4 100644 --- a/src/DabModulator.cpp +++ b/src/DabModulator.cpp @@ -163,10 +163,13 @@ int DabModulator::process(Buffer* dataOut) } } - auto cifCicEq = make_shared( + shared_ptr cifCicEq; + if (useCicEq) { + cifCicEq = make_shared( myNbCarriers, (float)mySpacing * (float)m_settings.outputRate / 2048000.0f, cic_ratio); + } shared_ptr tii; shared_ptr tiiRef; @@ -346,43 +349,24 @@ int DabModulator::process(Buffer* dataOut) myFlowgraph->connect(tii, cifSig); } - if (useCicEq) { - myFlowgraph->connect(cifSig, cifCicEq); - myFlowgraph->connect(cifCicEq, cifOfdm); - } - else { - myFlowgraph->connect(cifSig, cifOfdm); - } - myFlowgraph->connect(cifOfdm, cifGain); - myFlowgraph->connect(cifGain, cifGuard); - - auto cifOut = cifPoly ? - static_pointer_cast(cifPoly) : - static_pointer_cast(myOutput); - - if (cifFilter) { - myFlowgraph->connect(cifGuard, cifFilter); - if (cifRes) { - myFlowgraph->connect(cifFilter, cifRes); - myFlowgraph->connect(cifRes, cifOut); - } - else { - myFlowgraph->connect(cifFilter, cifOut); + shared_ptr prev_plugin = static_pointer_cast(cifSig); + const std::list > plugins({ + static_pointer_cast(cifCicEq), + static_pointer_cast(cifOfdm), + static_pointer_cast(cifGain), + static_pointer_cast(cifGuard), + static_pointer_cast(cifFilter), // optional block + static_pointer_cast(cifRes), // optional block + static_pointer_cast(cifPoly), // optional block + static_pointer_cast(myOutput), + }); + + for (auto& p : plugins) { + if (p) { + myFlowgraph->connect(prev_plugin, p); + prev_plugin = p; } } - else { - if (cifRes) { - myFlowgraph->connect(cifGuard, cifRes); - myFlowgraph->connect(cifRes, cifOut); - } - else { - myFlowgraph->connect(cifGuard, cifOut); - } - } - - if (cifPoly) { - myFlowgraph->connect(cifPoly, myOutput); - } } //////////////////////////////////////////////////////////////////// -- cgit v1.2.3