diff options
author | Jon Bergli Heier <snakebite@jvnv.net> | 2011-01-03 21:23:21 +0100 |
---|---|---|
committer | Jon Bergli Heier <snakebite@jvnv.net> | 2011-01-03 21:23:21 +0100 |
commit | 8149e0487f6e658af71339f41a4f2f8413876cf0 (patch) | |
tree | 4c82be20d6060a4d6e6b142bd518678cd19daddd | |
parent | daddac4d7ddb379b777cbe54c463777ae2402b29 (diff) |
Call encoder->flush() when done encoding.
-rw-r--r-- | encoder.h | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -5,6 +5,7 @@ #include <boost/iostreams/operations.hpp> #include <boost/shared_ptr.hpp> +#include <iostream> #include <string> class EncoderBase { @@ -26,7 +27,12 @@ class EncoderFilter : public boost::iostreams::multichar_input_filter { std::streamsize src_read = boost::iostreams::read(src, src_data, 0x2000); if(src_read < 0) src_read = 0; - return encoder->encode((const uint8_t*)src_data, src_read, (uint8_t*)s, n); + std::streamsize size = encoder->encode((const uint8_t*)src_data, src_read, (uint8_t*)s, n); + // no more data, flush encoder + if(src_read == 0 && size == 0) { + size = encoder->flush((uint8_t*)s, n); + } + return size; }; }; |