diff options
author | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-04-25 21:21:36 +0200 |
---|---|---|
committer | Matthias P. Braendli <matthias.braendli@mpb.li> | 2014-04-25 21:21:36 +0200 |
commit | ceb9dee04ca2bf6337da283fe92fb28e02a7e883 (patch) | |
tree | f170bf4b46045968efe90b4138c0a6a7d39b8d1e /src/dabplus-enc.cpp | |
parent | e8221339254261e0841316d191abfc4eb1381f4b (diff) | |
download | fdk-aac-dabplus-ceb9dee04ca2bf6337da283fe92fb28e02a7e883.tar.gz fdk-aac-dabplus-ceb9dee04ca2bf6337da283fe92fb28e02a7e883.tar.bz2 fdk-aac-dabplus-ceb9dee04ca2bf6337da283fe92fb28e02a7e883.zip |
Make the file output actually work
Diffstat (limited to 'src/dabplus-enc.cpp')
-rw-r--r-- | src/dabplus-enc.cpp | 53 |
1 files changed, 31 insertions, 22 deletions
diff --git a/src/dabplus-enc.cpp b/src/dabplus-enc.cpp index f45bc0a..fc6fa0f 100644 --- a/src/dabplus-enc.cpp +++ b/src/dabplus-enc.cpp @@ -212,7 +212,7 @@ int main(int argc, char *argv[]) int raw_input = 0; // For the file output - FILE *out_fh; + FILE *out_fh = NULL; const char *outuri = NULL; int sample_rate=48000, channels=2; @@ -667,29 +667,34 @@ int main(int argc, char *argv[]) } } - // ------------ ZeroMQ transmit - try { - 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); - - zmq_sock.send(zmqframebuf, ZMQ_FRAME_SIZE(zmq_frame_header), - ZMQ_DONTWAIT); - } - catch (zmq::error_t& e) { - fprintf(stderr, "ZeroMQ send error !\n"); - send_error_count ++; + if (out_fh) { + fwrite(outbuf, 1, outbuf_size, out_fh); } + else { + // ------------ ZeroMQ transmit + try { + 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); + + zmq_sock.send(zmqframebuf, ZMQ_FRAME_SIZE(zmq_frame_header), + ZMQ_DONTWAIT); + } + catch (zmq::error_t& e) { + fprintf(stderr, "ZeroMQ send error !\n"); + send_error_count ++; + } - if (send_error_count > 10) - { - fprintf(stderr, "ZeroMQ send failed ten times, aborting!\n"); - break; + if (send_error_count > 10) + { + fprintf(stderr, "ZeroMQ send failed ten times, aborting!\n"); + break; + } } if (out_args.numOutBytes + row*10 == outbuf_size) { @@ -719,6 +724,10 @@ int main(int argc, char *argv[]) } fprintf(stderr, "\n"); + if (out_fh) { + fclose(out_fh); + } + zmq_sock.close(); free_rs_char(rs_handler); |