summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-12-14 12:43:06 +0100
committerMax Kellermann <max@duempel.org>2013-12-14 12:43:06 +0100
commitd37b788ea81e4b282e3f24aa5cad31d85229cc30 (patch)
treee5bfb0d14e4bdf0c50a1ec34b73b0098b18fc685 /test
parentcb336ff666a8fb2958cfb35c36ffcf613b02cd70 (diff)
DecoderAPI: add function decoder_read_full()
Move code from the "mad" plugin.
Diffstat (limited to 'test')
-rw-r--r--test/FakeDecoderAPI.cxx18
-rw-r--r--test/run_decoder.cxx18
2 files changed, 36 insertions, 0 deletions
diff --git a/test/FakeDecoderAPI.cxx b/test/FakeDecoderAPI.cxx
index 469e37feb..ca09ca982 100644
--- a/test/FakeDecoderAPI.cxx
+++ b/test/FakeDecoderAPI.cxx
@@ -66,6 +66,24 @@ decoder_read(gcc_unused Decoder *decoder,
}
bool
+decoder_read_full(Decoder *decoder, InputStream &is,
+ void *_buffer, size_t size)
+{
+ uint8_t *buffer = (uint8_t *)_buffer;
+
+ while (size > 0) {
+ size_t nbytes = decoder_read(decoder, is, buffer, size);
+ if (nbytes == 0)
+ return false;
+
+ buffer += nbytes;
+ size -= nbytes;
+ }
+
+ return true;
+}
+
+bool
decoder_skip(Decoder *decoder, InputStream &is, size_t size)
{
while (size > 0) {
diff --git a/test/run_decoder.cxx b/test/run_decoder.cxx
index cab68c64e..7db8dde22 100644
--- a/test/run_decoder.cxx
+++ b/test/run_decoder.cxx
@@ -102,6 +102,24 @@ decoder_read(gcc_unused Decoder *decoder,
}
bool
+decoder_read_full(Decoder *decoder, InputStream &is,
+ void *_buffer, size_t size)
+{
+ uint8_t *buffer = (uint8_t *)_buffer;
+
+ while (size > 0) {
+ size_t nbytes = decoder_read(decoder, is, buffer, size);
+ if (nbytes == 0)
+ return false;
+
+ buffer += nbytes;
+ size -= nbytes;
+ }
+
+ return true;
+}
+
+bool
decoder_skip(Decoder *decoder, InputStream &is, size_t size)
{
while (size > 0) {