diff options
-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; }; }; |