summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-10-05 13:56:46 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-10-05 13:56:46 +0200
commit39e95f67515f97030f4e4dee03abde33ce35a99a (patch)
treeb779f300767bdff27b6383889fe93d7b731161e3 /src
parent0ae25898fb7bf360167cd9817db11f9cb2d2db65 (diff)
downloadODR-AudioEnc-39e95f67515f97030f4e4dee03abde33ce35a99a.tar.gz
ODR-AudioEnc-39e95f67515f97030f4e4dee03abde33ce35a99a.tar.bz2
ODR-AudioEnc-39e95f67515f97030f4e4dee03abde33ce35a99a.zip
Reformat whitespace, replace stringstream by to_string
Diffstat (limited to 'src')
-rw-r--r--src/odr-audioenc.cpp32
1 files changed, 15 insertions, 17 deletions
diff --git a/src/odr-audioenc.cpp b/src/odr-audioenc.cpp
index 5487b5c..8fc3808 100644
--- a/src/odr-audioenc.cpp
+++ b/src/odr-audioenc.cpp
@@ -439,7 +439,7 @@ int main(int argc, char *argv[])
/* For MOT Slideshow and DLS insertion */
const char* pad_fifo = "/tmp/pad.fifo";
- int pad_fd;
+ int pad_fd = -1;
int padlen = 0;
/* Encoder status, see the above STATUS macros */
@@ -971,29 +971,25 @@ int main(int argc, char *argv[])
if (padlen != 0) {
ssize_t pad_ret = read(pad_fd, pad_buf, padlen + 1);
- if((pad_ret < 0 && errno == EAGAIN) || pad_ret == 0) {
+ if ((pad_ret < 0 && errno == EAGAIN) || pad_ret == 0) {
// If this condition passes, there is no data to be read
}
- else if(pad_ret == padlen + 1) {
+ else if (pad_ret == padlen + 1) {
// Otherwise, you're good to go and buffer should contain "count" bytes.
calculated_padlen = pad_buf[padlen];
+
if (calculated_padlen < 2) {
- stringstream ss;
- ss << "Invalid X-PAD length " << calculated_padlen;
- throw runtime_error(ss.str());
+ throw runtime_error("Invalid X-PAD length " + to_string(calculated_padlen));
}
- /*
- * AAC: skip PAD if only zero F-PAD (saves four bytes)
+ /* AAC: skip PAD if only zero F-PAD (saves four bytes)
* See ยง5.4.3 in ETSI TS 102 563
*/
- if (
- selected_encoder == encoder_selection_t::fdk_dabplus &&
- calculated_padlen == 2 &&
- pad_buf[padlen - 2] == 0x00 &&
- pad_buf[padlen - 1] == 0x00
- ) {
- calculated_padlen = 0;
+ if ( selected_encoder == encoder_selection_t::fdk_dabplus &&
+ calculated_padlen == 2 &&
+ pad_buf[padlen - 2] == 0x00 &&
+ pad_buf[padlen - 1] == 0x00 ) {
+ calculated_padlen = 0;
}
}
else {
@@ -1002,8 +998,10 @@ int main(int argc, char *argv[])
break;
}
}
- if (calculated_padlen)
- status |= STATUS_PAD_INSERTED;
+
+ if (calculated_padlen > 0) {
+ status |= STATUS_PAD_INSERTED;
+ }
// -------------- Read Data