diff options
author | Max Kellermann <max@duempel.org> | 2009-10-03 16:17:02 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-10-03 16:17:02 +0200 |
commit | 7013f9fc3105a4e928cbd87bb177325e9b26bbc6 (patch) | |
tree | 353ca385fca5ab75aedabb2fd8948b2316e48afe /src/decoder_buffer.c | |
parent | 31cabc751d2dc6721706d878a0694afc83ef6a0c (diff) | |
parent | 325e380b8e44fd07a3e477e8fcfed9e6e1c80e7f (diff) | |
download | mpd-7013f9fc3105a4e928cbd87bb177325e9b26bbc6.tar.gz mpd-7013f9fc3105a4e928cbd87bb177325e9b26bbc6.tar.xz mpd-7013f9fc3105a4e928cbd87bb177325e9b26bbc6.zip |
Merged release 0.15.4 from branch 'v0.15.x'
Conflicts:
NEWS
configure.ac
Diffstat (limited to 'src/decoder_buffer.c')
-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; + } +} |