From bf7417981f2527348fb261f40f4de15f9b350db5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 14 Dec 2013 12:21:23 +0100 Subject: DecoderAPI: add function decoder_skip() Move code from the "mad" plugin. --- src/DecoderAPI.cxx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/DecoderAPI.cxx') diff --git a/src/DecoderAPI.cxx b/src/DecoderAPI.cxx index 4fea02bef..52b30cfb5 100644 --- a/src/DecoderAPI.cxx +++ b/src/DecoderAPI.cxx @@ -292,6 +292,22 @@ decoder_read(Decoder *decoder, return nbytes; } +bool +decoder_skip(Decoder *decoder, InputStream &is, size_t size) +{ + while (size > 0) { + char buffer[1024]; + size_t nbytes = decoder_read(decoder, is, buffer, + std::min(sizeof(buffer), size)); + if (nbytes == 0) + return false; + + size -= nbytes; + } + + return true; +} + void decoder_timestamp(Decoder &decoder, double t) { -- cgit v1.2.3