aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2021-02-24 10:18:07 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2021-02-24 10:18:07 +0100
commit6f5e28b0fa0e6a4cdc3c9f4e8f1cceac11d85798 (patch)
tree8575f501611d95c50df4f22b4ac64c7c99747d3c /src
parent233db5d21b9257f611883ffddc66e5dd26878e66 (diff)
downloadODR-AudioEnc-6f5e28b0fa0e6a4cdc3c9f4e8f1cceac11d85798.tar.gz
ODR-AudioEnc-6f5e28b0fa0e6a4cdc3c9f4e8f1cceac11d85798.tar.bz2
ODR-AudioEnc-6f5e28b0fa0e6a4cdc3c9f4e8f1cceac11d85798.zip
Add startupcheck
Diffstat (limited to 'src')
-rw-r--r--src/odr-audioenc.cpp28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/odr-audioenc.cpp b/src/odr-audioenc.cpp
index db3447b..068c8a3 100644
--- a/src/odr-audioenc.cpp
+++ b/src/odr-audioenc.cpp
@@ -1,6 +1,6 @@
/* ------------------------------------------------------------------
* Copyright (C) 2011 Martin Storsjo
- * Copyright (C) 2020 Matthias P. Braendli
+ * Copyright (C) 2021 Matthias P. Braendli
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -200,6 +200,7 @@ static void usage(const char* name)
" --fec=FEC Set EDI output FEC\n"
" -T, --timestamp-delay=DELAY_MS Enabled timestamps in EDI (requires TAI clock bulletin download) and\n"
" add a delay (in milliseconds) to the timestamps carried in EDI\n"
+ " --startup-check=SCRIPT_PATH Before starting, run the given script, and only start if it returns 0.\n"
" -k, --secret-key=FILE Enable ZMQ encryption with the given secret key.\n"
" -p, --pad=BYTES Enable PAD insertion and set PAD size in bytes.\n"
" -P, --pad-socket=IDENTIFIER Use the given identifier to communicate with ODR-PadEnc.\n"
@@ -1371,6 +1372,7 @@ int main(int argc, char *argv[])
{"rate", required_argument, 0, 'r'},
{"secret-key", required_argument, 0, 'k'},
{"silence", required_argument, 0, 's'},
+ {"startup-check", required_argument, 0, 9 },
{"stats", required_argument, 0, 'S'},
{"vlc-cache", required_argument, 0, 'C'},
{"vlc-gain", required_argument, 0, 'g'},
@@ -1423,6 +1425,8 @@ int main(int argc, char *argv[])
AudioEnc audio_enc;
+ std::string startupcheck;
+
int ch=0;
int index;
while(ch != -1) {
@@ -1472,6 +1476,9 @@ int main(int argc, char *argv[])
case 8: // EDI output FEC
audio_enc.edi_output.set_fec(std::stoi(optarg));
break;
+ case 9: // --startup-check
+ startupcheck = optarg;
+ break;
case 'a':
audio_enc.selected_encoder = encoder_selection_t::toolame_dab;
break;
@@ -1594,6 +1601,25 @@ int main(int argc, char *argv[])
}
}
+ if (not startupcheck.empty()) {
+ etiLog.level(info) << "Running startup check '" << startupcheck << "'";
+ int wstatus = system(startupcheck.c_str());
+
+ if (WIFEXITED(wstatus)) {
+ if (WEXITSTATUS(wstatus) == 0) {
+ etiLog.level(info) << "Startup check ok";
+ }
+ else {
+ etiLog.level(error) << "Startup check failed, returned " << WEXITSTATUS(wstatus);
+ return 1;
+ }
+ }
+ else {
+ etiLog.level(error) << "Startup check failed, child didn't terminate normally";
+ return 1;
+ }
+ }
+
try {
return audio_enc.run();
}