summaryrefslogtreecommitdiff
path: root/decoders
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2011-01-06 03:24:28 +0100
committerVegard Storheil Eriksen <zyp@jvnv.net>2011-01-06 03:24:28 +0100
commite755f01e631e832e3ef529049888d62af38d2b38 (patch)
tree1f2b8c8b888157cdd4c598541ebb8f26e9cc078f /decoders
parent70f111b184928feab0c94f762954b5ec83a441c6 (diff)
Change decoder/encoder API to provide decode/encode functions with a read callback function.
Diffstat (limited to 'decoders')
-rw-r--r--decoders/mpg123_decoder.cpp8
-rw-r--r--decoders/mpg123_decoder.h8
2 files changed, 14 insertions, 2 deletions
diff --git a/decoders/mpg123_decoder.cpp b/decoders/mpg123_decoder.cpp
index 0c2629f..0618320 100644
--- a/decoders/mpg123_decoder.cpp
+++ b/decoders/mpg123_decoder.cpp
@@ -48,3 +48,11 @@ size_t DecoderMpg123::decode(const uint8_t *input, size_t input_size, uint8_t *o
return output_written;
}
+
+size_t DecoderMpg123::decode(ReadFunc read, uint8_t *output, size_t output_size) {
+ char src_data[0x2000];
+ std::streamsize src_read = read(src_data, 0x2000);
+ if(src_read < 0)
+ src_read = 0;
+ return decode((const uint8_t*)src_data, src_read, (uint8_t*)output, output_size);
+}
diff --git a/decoders/mpg123_decoder.h b/decoders/mpg123_decoder.h
index 46f9e4c..5a637af 100644
--- a/decoders/mpg123_decoder.h
+++ b/decoders/mpg123_decoder.h
@@ -8,11 +8,15 @@
class DecoderMpg123 : public DecoderBase {
private:
mpg123_handle *handle;
-
+
+ size_t decode(const uint8_t *input, size_t input_size, uint8_t *output, size_t output_size);
+
+ protected:
+ virtual size_t decode(ReadFunc read, uint8_t *output, size_t output_size);
+
public:
DecoderMpg123();
~DecoderMpg123();
- size_t decode(const uint8_t *input, size_t input_size, uint8_t *output, size_t output_size);
};
#endif