diff options
author | Max Kellermann <max@duempel.org> | 2013-12-14 12:43:06 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-07-09 19:03:58 +0200 |
commit | 0759421d119d8d3d829978ede81683ca54d65d69 (patch) | |
tree | ecb6968a7842e6b12de5f2c8b1e194358d697872 /src/DecoderAPI.cxx | |
parent | bf7417981f2527348fb261f40f4de15f9b350db5 (diff) | |
download | mpd-0759421d119d8d3d829978ede81683ca54d65d69.tar.gz mpd-0759421d119d8d3d829978ede81683ca54d65d69.tar.xz mpd-0759421d119d8d3d829978ede81683ca54d65d69.zip |
DecoderAPI: add function decoder_read_full()
Move code from the "mad" plugin.
Diffstat (limited to 'src/DecoderAPI.cxx')
-rw-r--r-- | src/DecoderAPI.cxx | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/DecoderAPI.cxx b/src/DecoderAPI.cxx index 52b30cfb5..e4122d60e 100644 --- a/src/DecoderAPI.cxx +++ b/src/DecoderAPI.cxx @@ -293,6 +293,24 @@ decoder_read(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) { |