From 8f13b3f2580f182f51d9ad131da1deafdcd5e91a Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 25 Apr 2014 15:12:24 +0200 Subject: use new message format for file encoder too --- src/dabplus-enc-file-zmq.c | 19 ++++++++++++++++--- src/utils.h | 4 ++-- 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/dabplus-enc-file-zmq.c b/src/dabplus-enc-file-zmq.c index 106e110..1bfae12 100644 --- a/src/dabplus-enc-file-zmq.c +++ b/src/dabplus-enc-file-zmq.c @@ -412,9 +412,12 @@ int main(int argc, char *argv[]) { return 0; } - int loops = 0; int outbuf_size = subchannel_index*120; - uint8_t outbuf[20480]; + uint8_t zmqframebuf[2048]; + struct zmq_frame_header_t *zmq_frame_header = + (struct zmq_frame_header_t*)zmqframebuf; + + uint8_t outbuf[2048]; if(outbuf_size % 5 != 0) { fprintf(stderr, "(outbuf_size mod 5) = %d\n", outbuf_size % 5); @@ -554,7 +557,17 @@ int main(int argc, char *argv[]) { } if (zmq_sock) { - send_error = zmq_send(zmq_sock, outbuf, outbuf_size, ZMQ_DONTWAIT); + zmq_frame_header->version = 1; + zmq_frame_header->encoder = ZMQ_ENCODER_FDK; + zmq_frame_header->datasize = outbuf_size; + zmq_frame_header->audiolevel_left = peak_left; + zmq_frame_header->audiolevel_right = peak_right; + + memcpy(ZMQ_FRAME_DATA(zmq_frame_header), + outbuf, outbuf_size); + + send_error = zmq_send(zmq_sock, zmqframebuf, + ZMQ_FRAME_SIZE(zmq_frame_header), ZMQ_DONTWAIT); if (send_error < 0) { fprintf(stderr, "ZeroMQ send failed! %s\n", zmq_strerror(errno)); send_error_count ++; diff --git a/src/utils.h b/src/utils.h index aa8dc8a..a5aaf8c 100644 --- a/src/utils.h +++ b/src/utils.h @@ -37,9 +37,9 @@ struct zmq_frame_header_t #define ZMQ_ENCODER_FDK 1 /* The expected frame size incl data of the given frame */ -#define ZMQ_FRAME_SIZE(f) (sizeof(zmq_frame_header_t) + f->datasize) +#define ZMQ_FRAME_SIZE(f) (sizeof(struct zmq_frame_header_t) + f->datasize) -#define ZMQ_FRAME_DATA(f) ( ((uint8_t*)f)+sizeof(zmq_frame_header_t) ) +#define ZMQ_FRAME_DATA(f) ( ((uint8_t*)f)+sizeof(struct zmq_frame_header_t) ) #endif -- cgit v1.2.3