aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2020-04-21 15:39:26 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2020-04-21 15:39:26 +0200
commit8c478b0fd3988c1967bb1040fd97d5b4ac9a4ff4 (patch)
tree4ad5a0ea151f2117845eda1acf6c820076014ef9
parentb1438d4fa31aa9e967f1f7e2d48f55ca371151d1 (diff)
downloadODR-AudioEnc-8c478b0fd3988c1967bb1040fd97d5b4ac9a4ff4.tar.gz
ODR-AudioEnc-8c478b0fd3988c1967bb1040fd97d5b4ac9a4ff4.tar.bz2
ODR-AudioEnc-8c478b0fd3988c1967bb1040fd97d5b4ac9a4ff4.zip
Fix multi output when combining EDI and ZMQ
-rw-r--r--contrib/Socket.cpp4
-rw-r--r--contrib/Socket.h2
-rw-r--r--contrib/edi/Transport.cpp4
-rw-r--r--src/odr-audioenc.cpp21
4 files changed, 18 insertions, 13 deletions
diff --git a/contrib/Socket.cpp b/contrib/Socket.cpp
index 8b8d0e2..159de7e 100644
--- a/contrib/Socket.cpp
+++ b/contrib/Socket.cpp
@@ -925,13 +925,13 @@ TCPSendClient::~TCPSendClient()
}
}
-void TCPSendClient::sendall(std::vector<uint8_t>&& buffer)
+void TCPSendClient::sendall(const std::vector<uint8_t>& buffer)
{
if (not m_running) {
throw runtime_error(m_exception_data);
}
- m_queue.push(move(buffer));
+ m_queue.push(buffer);
}
void TCPSendClient::process()
diff --git a/contrib/Socket.h b/contrib/Socket.h
index b342d8b..84def40 100644
--- a/contrib/Socket.h
+++ b/contrib/Socket.h
@@ -300,7 +300,7 @@ class TCPSendClient {
/* Throws a runtime_error on error
*/
- void sendall(std::vector<uint8_t>&& buffer);
+ void sendall(const std::vector<uint8_t>& buffer);
private:
void process();
diff --git a/contrib/edi/Transport.cpp b/contrib/edi/Transport.cpp
index c7bde8f..4c91483 100644
--- a/contrib/edi/Transport.cpp
+++ b/contrib/edi/Transport.cpp
@@ -149,7 +149,7 @@ void Sender::write(const TagPacket& tagpacket)
tcp_dispatchers.at(tcp_dest.get())->write(edi_frag);
}
else if (auto tcp_dest = dynamic_pointer_cast<edi::tcp_client_t>(dest)) {
- tcp_senders.at(tcp_dest.get())->sendall(move(edi_frag));
+ tcp_senders.at(tcp_dest.get())->sendall(edi_frag);
}
else {
throw logic_error("EDI destination not implemented");
@@ -175,7 +175,7 @@ void Sender::write(const TagPacket& tagpacket)
tcp_dispatchers.at(tcp_dest.get())->write(af_packet);
}
else if (auto tcp_dest = dynamic_pointer_cast<edi::tcp_client_t>(dest)) {
- tcp_senders.at(tcp_dest.get())->sendall(move(af_packet));
+ tcp_senders.at(tcp_dest.get())->sendall(af_packet);
}
else {
throw logic_error("EDI destination not implemented");
diff --git a/src/odr-audioenc.cpp b/src/odr-audioenc.cpp
index 97b562f..94f5678 100644
--- a/src/odr-audioenc.cpp
+++ b/src/odr-audioenc.cpp
@@ -1262,15 +1262,19 @@ int AudioEnc::run()
bool AudioEnc::send_frame(const uint8_t *buf, size_t len, int16_t peak_left, int16_t peak_right)
{
+ // The file output is mutually exclusive to the other outputs
if (file_output) {
file_output->update_audio_levels(peak_left, peak_right);
return file_output->write_frame(buf, len);
}
- else if (zmq_output) {
+
+ bool success = true;
+ if (zmq_output) {
zmq_output->update_audio_levels(peak_left, peak_right);
- return zmq_output->write_frame(buf, len);
+ success &= zmq_output->write_frame(buf, len);
}
- else if (edi_output.enabled()) {
+
+ if (edi_output.enabled()) {
edi_output.update_audio_levels(peak_left, peak_right);
switch (selected_encoder) {
case encoder_selection_t::fdk_dabplus:
@@ -1283,18 +1287,19 @@ bool AudioEnc::send_frame(const uint8_t *buf, size_t len, int16_t peak_left, int
const size_t blocksize = len/5;
for (size_t i = 0; i < 5; i++) {
- bool success = edi_output.write_frame(buf + i * blocksize, blocksize);
+ success &= edi_output.write_frame(buf + i * blocksize, blocksize);
if (not success) {
- return false;
+ break;
}
}
- return true;
}
+ break;
case encoder_selection_t::toolame_dab:
- return edi_output.write_frame(buf, len);
+ success &= edi_output.write_frame(buf, len);
+ break;
}
}
- return false;
+ return success;
}
AudioEnc::~AudioEnc()