summaryrefslogtreecommitdiffstats
path: root/src/DabMod.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/DabMod.cpp')
-rw-r--r--src/DabMod.cpp64
1 files changed, 41 insertions, 23 deletions
diff --git a/src/DabMod.cpp b/src/DabMod.cpp
index dc61ae2..82f03e5 100644
--- a/src/DabMod.cpp
+++ b/src/DabMod.cpp
@@ -72,13 +72,13 @@
typedef std::complex<float> complexf;
-bool running = true;
+volatile sig_atomic_t running = 1;
void signalHandler(int signalNb)
{
PDEBUG("signalHandler(%i)\n", signalNb);
- running = false;
+ running = 0;
}
@@ -223,16 +223,23 @@ int main(int argc, char* argv[])
FormatConverter* format_converter = NULL;
ModOutput* output = NULL;
- BaseRemoteController* rc = NULL;
+ RemoteControllers rcs;
Logger logger;
InputFileReader inputFileReader(logger);
-#if defined(HAVE_INPUT_ZEROMQ)
+#if defined(HAVE_ZEROMQ)
InputZeroMQReader inputZeroMQReader(logger);
#endif
InputReader* inputReader;
- signal(SIGINT, signalHandler);
+ struct sigaction sa;
+ memset(&sa, 0, sizeof(struct sigaction));
+ sa.sa_handler = &signalHandler;
+
+ if (sigaction(SIGINT, &sa, NULL) == -1) {
+ perror("sigaction");
+ return EXIT_FAILURE;
+ }
// Set timezone to UTC
setenv("TZ", "", 1);
@@ -366,15 +373,12 @@ int main(int argc, char* argv[])
"\n";
std::cerr << "Compiled with features: " <<
-#if defined(HAVE_INPUT_ZEROMQ)
- "input_zeromq " <<
+#if defined(HAVE_ZEROMQ)
+ "zeromq " <<
#endif
#if defined(HAVE_OUTPUT_UHD)
"output_uhd " <<
#endif
-#if defined(HAVE_OUTPUT_ZEROMQ)
- "output_zeromq " <<
-#endif
"\n";
if (use_configuration_file && use_configuration_cmdline) {
@@ -413,7 +417,7 @@ int main(int argc, char* argv[])
try {
int telnetport = pt.get<int>("remotecontrol.telnetport");
RemoteControllerTelnet* telnetrc = new RemoteControllerTelnet(telnetport);
- rc = telnetrc;
+ rcs.add_controller(telnetrc);
}
catch (std::exception &e) {
std::cerr << "Error: " << e.what() << "\n";
@@ -422,6 +426,22 @@ int main(int argc, char* argv[])
}
}
+#if defined(HAVE_ZEROMQ)
+ if (pt.get("remotecontrol.zmqctrl", 0) == 1) {
+ try {
+ std::string zmqCtrlEndpoint = pt.get("remotecontrol.zmqctrlendpoint", "");
+ std::cerr << "ZmqCtrlEndpoint: " << zmqCtrlEndpoint << std::endl;
+ RemoteControllerZmq* zmqrc = new RemoteControllerZmq(zmqCtrlEndpoint);
+ rcs.add_controller(zmqrc);
+ }
+ catch (std::exception &e) {
+ std::cerr << "Error: " << e.what() << "\n";
+ std::cerr << " zmq remote control enabled, but no endpoint defined.\n";
+ goto END_MAIN;
+ }
+ }
+#endif
+
// input params:
if (pt.get("input.loop", 0) == 1) {
loop = true;
@@ -592,7 +612,7 @@ int main(int argc, char* argv[])
useUHDOutput = 1;
}
#endif
-#if defined(HAVE_OUTPUT_ZEROMQ)
+#if defined(HAVE_ZEROMQ)
else if (output_selected == "zmq") {
outputName = pt.get<std::string>("zmqoutput.listen");
useZeroMQOutput = 1;
@@ -631,9 +651,9 @@ int main(int argc, char* argv[])
#endif
}
- if (!rc) {
+ if (rcs.get_no_controllers() == 0) {
logger.level(warn) << "No Remote-Control started";
- rc = new RemoteControllerDummy();
+ rcs.add_controller(new RemoteControllerDummy());
}
@@ -735,7 +755,7 @@ int main(int argc, char* argv[])
inputReader = &inputFileReader;
}
else if (inputTransport == "zeromq") {
-#if !defined(HAVE_INPUT_ZEROMQ)
+#if !defined(HAVE_ZEROMQ)
fprintf(stderr, "Error, ZeroMQ input transport selected, but not compiled in!\n");
ret = -1;
goto END_MAIN;
@@ -778,7 +798,7 @@ int main(int argc, char* argv[])
outputuhd_conf.sampleRate = outputRate;
try {
output = new OutputUHD(outputuhd_conf, logger);
- ((OutputUHD*)output)->enrol_at(*rc);
+ ((OutputUHD*)output)->enrol_at(rcs);
}
catch (std::exception& e) {
logger.level(error) << "UHD initialisation failed:" << e.what();
@@ -786,7 +806,7 @@ int main(int argc, char* argv[])
}
}
#endif
-#if defined(HAVE_OUTPUT_ZEROMQ)
+#if defined(HAVE_ZEROMQ)
else if (useZeroMQOutput) {
/* We normalise the same way as for the UHD output */
normalise = 1.0f / normalise_factor;
@@ -798,7 +818,7 @@ int main(int argc, char* argv[])
flowgraph = new Flowgraph();
data.setLength(6144);
input = new InputMemory(&data);
- modulator = new DabModulator(modconf, rc, logger, outputRate, clockRate,
+ modulator = new DabModulator(modconf, &rcs, logger, outputRate, clockRate,
dabMode, gainMode, digitalgain, normalise, filterTapsFilename);
flowgraph->connect(input, modulator);
if (format_converter) {
@@ -843,10 +863,8 @@ int main(int argc, char* argv[])
/* Check every once in a while if the remote control
* is still working */
- if (rc && (frame % 250) == 0 && rc->fault_detected()) {
- fprintf(stderr,
- "Detected Remote Control fault, restarting it\n");
- rc->restart();
+ if (rcs.get_no_controllers() > 0 && (frame % 250) == 0) {
+ rcs.check_faults();
}
}
if (framesize == 0) {
@@ -855,7 +873,7 @@ int main(int argc, char* argv[])
else {
fprintf(stderr, "Input read error.\n");
}
- running = false;
+ running = 0;
}
} catch (std::exception& e) {
fprintf(stderr, "EXCEPTION: %s\n", e.what());