aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorStefan Pöschel <github@basicmaster.de>2017-04-07 23:43:23 +0200
committerStefan Pöschel <github@basicmaster.de>2017-04-07 23:43:23 +0200
commit78ca13d1a7d837008ef5339746773b2abbf3ca2f (patch)
tree49e9024536af1f5bd19a8e2f29b7775fb8655c23 /src
parentb2253d99cba9dabf8afaec030a2c9f7c1fe623d5 (diff)
downloadODR-PadEnc-78ca13d1a7d837008ef5339746773b2abbf3ca2f.tar.gz
ODR-PadEnc-78ca13d1a7d837008ef5339746773b2abbf3ca2f.tar.bz2
ODR-PadEnc-78ca13d1a7d837008ef5339746773b2abbf3ca2f.zip
Add recovery on broken pipe
When the opposite side of the PAD FIFO disconnects (e.g. due to crash of the audio encoder), ODR-PadEnc crashed as well due to SIGPIPE. This commit changes the behaviour. From now on instead error messages are displayed and it is possible for a new instance of the audio encoder to reconnect to the still running ODR-PadEnc instance.
Diffstat (limited to 'src')
-rw-r--r--src/odr-padenc.cpp4
-rw-r--r--src/pad_common.cpp12
2 files changed, 14 insertions, 2 deletions
diff --git a/src/odr-padenc.cpp b/src/odr-padenc.cpp
index c42ddf0..2fd3a47 100644
--- a/src/odr-padenc.cpp
+++ b/src/odr-padenc.cpp
@@ -168,6 +168,10 @@ int main(int argc, char *argv[]) {
perror("ODR-PadEnc Error: could not set SIGTERM handler");
return 1;
}
+ if(signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
+ perror("ODR-PadEnc Error: could not set SIGPIPE to be ignored");
+ return 1;
+ }
size_t padlen = 58;
bool erase_after_tx = false;
diff --git a/src/pad_common.cpp b/src/pad_common.cpp
index 4d2d9af..5ba4c7f 100644
--- a/src/pad_common.cpp
+++ b/src/pad_common.cpp
@@ -132,6 +132,9 @@ pad_t* PADPacketizer::GetPAD() {
}
void PADPacketizer::WriteAllPADs(int output_fd, int limit) {
+ size_t error_count = 0;
+ size_t error_bytes = 0;
+
// output a limited amount of PADs (-1 = no limit)
for (int i = 0; i != limit; i++) {
pad_t* pad = GetPAD();
@@ -142,11 +145,16 @@ void PADPacketizer::WriteAllPADs(int output_fd, int limit) {
break;
}
- if (write(output_fd, &(*pad)[0], pad->size()) != (signed) pad->size())
- fprintf(stderr, "ODR-PadEnc Error: Could not write PAD\n");
+ if (write(output_fd, &(*pad)[0], pad->size()) != (signed) pad->size()) {
+ error_count++;
+ error_bytes += pad->size();
+ }
delete pad;
}
+
+ if (error_count)
+ fprintf(stderr, "ODR-PadEnc Error: Could not write %zu PAD(s) with %zu Bytes\n", error_count, error_bytes);
}