diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-02-11 11:57:12 +0100 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-02-11 11:57:12 +0100 |
commit | 7106542cddeef3c0e0df05d2993c83f9cf53472c (patch) | |
tree | 0c5bda3f77a1211255fe2d14e60c74c1987556d1 /src/dabInputZmq.cpp | |
parent | e10070a508cdeb7d6a0f2aa5c2657352d5d582c2 (diff) | |
download | dabmux-7106542cddeef3c0e0df05d2993c83f9cf53472c.tar.gz dabmux-7106542cddeef3c0e0df05d2993c83f9cf53472c.tar.bz2 dabmux-7106542cddeef3c0e0df05d2993c83f9cf53472c.zip |
Add zmq.hpp locally, prefer it over the system one. Fix usage of zmq.recv
Diffstat (limited to 'src/dabInputZmq.cpp')
-rw-r--r-- | src/dabInputZmq.cpp | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/src/dabInputZmq.cpp b/src/dabInputZmq.cpp index d0cf6b7..b54cddc 100644 --- a/src/dabInputZmq.cpp +++ b/src/dabInputZmq.cpp @@ -35,6 +35,7 @@ #include "dabInput.h" #include "dabInputZmq.h" #include "StatsServer.h" +#include "zmq.hpp" #ifdef HAVE_CONFIG_H # include "config.h" @@ -43,7 +44,6 @@ #ifdef HAVE_INPUT_ZEROMQ #include <stdio.h> -#include <zmq.hpp> #include <list> #include <exception> #include <string.h> @@ -174,14 +174,15 @@ int DabInputZmq::readFrame(void* buffer, int size) int DabInputZmq::readFromSocket(int framesize) { int rc; - int nBytes; + bool messageReceived; zmq::message_t msg; try { - nBytes = m_zmq_sock.recv(&msg, ZMQ_DONTWAIT); - if (nBytes == 0) { + messageReceived = m_zmq_sock.recv(&msg, ZMQ_DONTWAIT); + if (!messageReceived) { return 0; } + } catch (zmq::error_t& err) { @@ -195,14 +196,14 @@ int DabInputZmq::readFromSocket(int framesize) * Audio super frames are transported in five successive DAB logical frames * with additional error protection. */ - if (nBytes == 5*framesize) + if (msg.size() == 5*framesize) { if (m_frame_buffer.size() > INPUT_ZMQ_MAX_BUFFER_SIZE) { etiLog.level(warn) << "inputZMQ " << m_name << " buffer full (" << m_frame_buffer.size() << ")," " dropping incoming superframe !"; - nBytes = 0; + messageReceived = 0; } else { // copy the input frame blockwise into the frame_buffer @@ -215,16 +216,14 @@ int DabInputZmq::readFromSocket(int framesize) } } } - else - { + else { etiLog.level(error) << "inputZMQ " << m_name << - " wrong data size: recv'd " << nBytes << + " wrong data size: recv'd " << msg.size() << ", need " << 5*framesize << "."; - nBytes = 0; } - return nBytes; + return msg.size(); } int DabInputZmq::close() |