summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2011-01-03 21:23:21 +0100
committerJon Bergli Heier <snakebite@jvnv.net>2011-01-03 21:23:21 +0100
commit8149e0487f6e658af71339f41a4f2f8413876cf0 (patch)
tree4c82be20d6060a4d6e6b142bd518678cd19daddd
parentdaddac4d7ddb379b777cbe54c463777ae2402b29 (diff)
Call encoder->flush() when done encoding.
-rw-r--r--encoder.h8
1 files changed, 7 insertions, 1 deletions
diff --git a/encoder.h b/encoder.h
index c0e3d6a..14ecfeb 100644
--- a/encoder.h
+++ b/encoder.h
@@ -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;
};
};