summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2016-01-31 22:35:17 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2016-01-31 22:35:17 +0100
commit5ac4621df043666836107e0e0aaa3df709fb866e (patch)
treeb11ea1bff6c671597adcc46ed8dfe2593fee38a9
parentf607e5406666dbd1646b427af9b46c956829a773 (diff)
downloaddabmod-5ac4621df043666836107e0e0aaa3df709fb866e.tar.gz
dabmod-5ac4621df043666836107e0e0aaa3df709fb866e.tar.bz2
dabmod-5ac4621df043666836107e0e0aaa3df709fb866e.zip
Restart when FrameMultiplexer sees a different configuration
-rw-r--r--src/DabMod.cpp42
-rw-r--r--src/FrameMultiplexer.cpp10
2 files changed, 35 insertions, 17 deletions
diff --git a/src/DabMod.cpp b/src/DabMod.cpp
index f250850..57ff79b 100644
--- a/src/DabMod.cpp
+++ b/src/DabMod.cpp
@@ -105,13 +105,14 @@ struct modulator_data
RemoteControllers* rcs;
};
-enum run_modulator_state {
- MOD_FAILURE,
- MOD_NORMAL_END,
- MOD_AGAIN
+enum class run_modulator_state_t {
+ failure, // Corresponds to all failures
+ normal_end, // Number of frames to modulate was reached
+ again, // FCT discontinuity or ZeroMQ overrun
+ reconfigure // Some sort of change of configuration we cannot handle happened
};
-run_modulator_state run_modulator(modulator_data& m);
+run_modulator_state_t run_modulator(modulator_data& m);
int launch_modulator(int argc, char* argv[])
{
@@ -786,15 +787,15 @@ int launch_modulator(int argc, char* argv[])
m.inputReader->PrintInfo();
- run_modulator_state st = run_modulator(m);
+ run_modulator_state_t st = run_modulator(m);
switch (st) {
- case MOD_FAILURE:
+ case run_modulator_state_t::failure:
etiLog.level(error) << "Modulator failure.";
run_again = false;
ret = 1;
break;
- case MOD_AGAIN:
+ case run_modulator_state_t::again:
etiLog.level(warn) << "Restart modulator.";
run_again = false;
if (inputTransport == "file") {
@@ -816,7 +817,12 @@ int launch_modulator(int argc, char* argv[])
#endif
}
break;
- case MOD_NORMAL_END:
+ case run_modulator_state_t::reconfigure:
+ etiLog.level(warn) << "Detected change in ensemble configuration.";
+ /* We can keep the input in this care */
+ run_again = true;
+ break;
+ case run_modulator_state_t::normal_end:
default:
etiLog.level(info) << "modulator stopped.";
ret = 0;
@@ -839,9 +845,9 @@ int launch_modulator(int argc, char* argv[])
return ret;
}
-run_modulator_state run_modulator(modulator_data& m)
+run_modulator_state_t run_modulator(modulator_data& m)
{
- run_modulator_state ret = MOD_FAILURE;
+ auto ret = run_modulator_state_t::failure;
try {
while (running) {
@@ -879,21 +885,27 @@ run_modulator_state run_modulator(modulator_data& m)
etiLog.level(error) << "Input read error.";
}
running = 0;
- ret = MOD_NORMAL_END;
+ ret = run_modulator_state_t::normal_end;
}
#if defined(HAVE_OUTPUT_UHD)
} catch (fct_discontinuity_error& e) {
// The OutputUHD saw a FCT discontinuity
etiLog.level(warn) << e.what();
- ret = MOD_AGAIN;
+ ret = run_modulator_state_t::again;
#endif
} catch (zmq_input_overflow& e) {
// The ZeroMQ input has overflowed its buffer
etiLog.level(warn) << e.what();
- ret = MOD_AGAIN;
+ ret = run_modulator_state_t::again;
+ } catch (std::out_of_range& e) {
+ // One of the DSP blocks has detected an invalid change
+ // or value in some settings. This can be due to a multiplex
+ // reconfiguration.
+ etiLog.level(warn) << e.what();
+ ret = run_modulator_state_t::reconfigure;
} catch (std::exception& e) {
etiLog.level(error) << "Exception caught: " << e.what();
- ret = MOD_FAILURE;
+ ret = run_modulator_state_t::failure;
}
return ret;
diff --git a/src/FrameMultiplexer.cpp b/src/FrameMultiplexer.cpp
index efd43f3..ffae2ca 100644
--- a/src/FrameMultiplexer.cpp
+++ b/src/FrameMultiplexer.cpp
@@ -77,11 +77,17 @@ int FrameMultiplexer::process(std::vector<Buffer*> dataIn, Buffer* dataOut)
memcpy(out, (*in)->getData(), (*in)->getLength());
++in;
// Write subchannel
- assert(mySubchannels->size() == dataIn.size() - 1);
+ if (mySubchannels->size() != dataIn.size() - 1) {
+ throw std::out_of_range(
+ "FrameMultiplexer detected subchannel size change!");
+ }
std::vector<std::shared_ptr<SubchannelSource> >::const_iterator subchannel =
mySubchannels->begin();
while (in != dataIn.end()) {
- assert((*subchannel)->framesizeCu() * 8 == (*in)->getLength());
+ if ((*subchannel)->framesizeCu() * 8 != (*in)->getLength()) {
+ throw std::out_of_range(
+ "FrameMultiplexer detected invalid subchannel size!");
+ }
size_t offset = (*subchannel)->startAddress() * 8;
memcpy(&out[offset], (*in)->getData(), (*in)->getLength());
++in;