summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-04-10 15:31:15 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-04-10 15:31:15 +0200
commit8270567bc62db8f94a6e142b3b170a3bb943c090 (patch)
tree8055870c22eb2270776f031c68a22402b8a2804c
parentf7866047042030e657eb2fa0cd6cf2ad383d61bd (diff)
downloaddabmod-8270567bc62db8f94a6e142b3b170a3bb943c090.tar.gz
dabmod-8270567bc62db8f94a6e142b3b170a3bb943c090.tar.bz2
dabmod-8270567bc62db8f94a6e142b3b170a3bb943c090.zip
Avoid having exceptions triggering abort()
-rw-r--r--src/DabMod.cpp18
-rw-r--r--src/Utils.cpp2
2 files changed, 18 insertions, 2 deletions
diff --git a/src/DabMod.cpp b/src/DabMod.cpp
index b713d30..ec1a4cd 100644
--- a/src/DabMod.cpp
+++ b/src/DabMod.cpp
@@ -110,7 +110,7 @@ enum run_modulator_state {
run_modulator_state run_modulator(Logger& logger, modulator_data& m);
-int main(int argc, char* argv[])
+int launch_modulator(int argc, char* argv[])
{
int ret = 0;
bool loop = false;
@@ -899,3 +899,19 @@ run_modulator_state run_modulator(Logger& logger, modulator_data& m)
return ret;
}
+int main(int argc, char* argv[])
+{
+ try {
+ return launch_modulator(argc, argv);
+ }
+ catch (std::invalid_argument& e) {
+ std::string what(e.what());
+ if (not what.empty()) {
+ std::cerr << "Modulator error: " << what << std::endl;
+ }
+ }
+ catch (std::runtime_error& e) {
+ std::cerr << "Modulator runtime error: " << e.what() << std::endl;
+ }
+}
+
diff --git a/src/Utils.cpp b/src/Utils.cpp
index 8698f6e..8b97602 100644
--- a/src/Utils.cpp
+++ b/src/Utils.cpp
@@ -79,7 +79,7 @@ void printUsage(char* progName)
fprintf(out, "-h: Print this help.\n");
fprintf(out, "-l: Loop file when reach end of file.\n");
fprintf(out, "-m mode: Set DAB mode: (0: auto, 1-4: force).\n");
- fprintf(out, "-r rate: Set output sampling rate (default: 2048000).\n");
+ fprintf(out, "-r rate: Set output sampling rate (default: 2048000).\n\n");
}