diff options
author | Stefan Pöschel <github@basicmaster.de> | 2017-04-07 23:43:23 +0200 |
---|---|---|
committer | Stefan Pöschel <github@basicmaster.de> | 2017-04-07 23:43:23 +0200 |
commit | 78ca13d1a7d837008ef5339746773b2abbf3ca2f (patch) | |
tree | 49e9024536af1f5bd19a8e2f29b7775fb8655c23 /src/pad_common.cpp | |
parent | b2253d99cba9dabf8afaec030a2c9f7c1fe623d5 (diff) | |
download | ODR-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/pad_common.cpp')
-rw-r--r-- | src/pad_common.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
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); } |