diff options
author | Max Kellermann <max@duempel.org> | 2009-09-30 15:22:36 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-09-30 15:22:36 +0200 |
commit | efb290073bfecfb051a9839ec30fb5c57524640d (patch) | |
tree | 5310da5082c17fa47fbc03454392d463b484aab7 /src/decoder_buffer.c | |
parent | 82c6c137808264cc84220274f8ab57e8c47d7772 (diff) | |
download | mpd-efb290073bfecfb051a9839ec30fb5c57524640d.tar.gz mpd-efb290073bfecfb051a9839ec30fb5c57524640d.tar.xz mpd-efb290073bfecfb051a9839ec30fb5c57524640d.zip |
decoder_buffer: added function decoder_buffer_skip()
Diffstat (limited to '')
-rw-r--r-- | src/decoder_buffer.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/decoder_buffer.c b/src/decoder_buffer.c index 76e9126ef..b6fa90004 100644 --- a/src/decoder_buffer.c +++ b/src/decoder_buffer.c @@ -138,3 +138,29 @@ decoder_buffer_consume(struct decoder_buffer *buffer, size_t nbytes) assert(buffer->consumed <= buffer->length); } + +bool +decoder_buffer_skip(struct decoder_buffer *buffer, size_t nbytes) +{ + size_t length; + const void *data; + bool success; + + /* this could probably be optimized by seeking */ + + while (true) { + data = decoder_buffer_read(buffer, &length); + if (data != NULL) { + if (length > nbytes) + length = nbytes; + decoder_buffer_consume(buffer, length); + nbytes -= length; + if (nbytes == 0) + return true; + } + + success = decoder_buffer_fill(buffer); + if (!success) + return false; + } +} |