From f99c4f75d7c1ffc18e3d04167e854af3d571f1b1 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 3 Jul 2015 08:05:36 +0200 Subject: Add dumb reconfigure to DabMultiplexer --- src/DabMultiplexer.cpp | 27 +++++++++++++++------------ src/DabMultiplexer.h | 5 +++++ 2 files changed, 20 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/DabMultiplexer.cpp b/src/DabMultiplexer.cpp index 413e034..5c41d99 100644 --- a/src/DabMultiplexer.cpp +++ b/src/DabMultiplexer.cpp @@ -25,6 +25,7 @@ #include "DabMultiplexer.h" #include "ConfigParser.h" +#include using namespace std; using namespace boost; @@ -88,7 +89,7 @@ DabMultiplexer::DabMultiplexer( { prepare_watermark(); - ensemble = boost::shared_ptr(new dabEnsemble); + ensemble = boost::make_shared(); } void DabMultiplexer::prepare_watermark() @@ -118,13 +119,16 @@ void DabMultiplexer::prepare_watermark() void DabMultiplexer::update_config(boost::property_tree::ptree pt) { - ensemble->services.clear(); - ensemble->components.clear(); - ensemble->subchannels.clear(); + ensemble_next = boost::make_shared(); - m_pt = pt; + m_pt_next = pt; - prepare(); + reconfigure(); +} + +void DabMultiplexer::reconfigure() +{ + parse_ptree(m_pt_next, ensemble_next, m_rc, &edi_conf); } // Run a set of checks on the configuration @@ -195,16 +199,15 @@ void DabMultiplexer::prepare() void DabMultiplexer::prepare_subchannels() { set ids; - vector::iterator subchannel; - for (subchannel = ensemble->subchannels.begin(); - subchannel != ensemble->subchannels.end(); - ++subchannel) { - if (ids.find((*subchannel)->id) != ids.end()) { + + for (auto subchannel : ensemble->subchannels) { + if (ids.find(subchannel->id) != ids.end()) { etiLog.log(error, "Subchannel %u is set more than once!\n", - (*subchannel)->id); + subchannel->id); throw MuxInitException(); } + ids.insert(subchannel->id); } } diff --git a/src/DabMultiplexer.h b/src/DabMultiplexer.h index e9843fc..9761ef9 100644 --- a/src/DabMultiplexer.h +++ b/src/DabMultiplexer.h @@ -82,6 +82,7 @@ class DabMultiplexer { void prepare_subchannels(void); void prepare_services_components(void); void prepare_data_inputs(void); + void reconfigure(void); boost::property_tree::ptree m_pt; boost::shared_ptr m_rc; @@ -118,6 +119,10 @@ class DabMultiplexer { std::vector::iterator subchannelFIG0_1; boost::shared_ptr ensemble; + + // Multiplex reconfiguration requires two sets of configurations + boost::property_tree::ptree m_pt_next; + boost::shared_ptr ensemble_next; }; // DAB Mode -- cgit v1.2.3