aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2014-07-12 02:26:38 +0200
committerMax Kellermann <max@duempel.org>2014-07-12 02:26:38 +0200
commit543a58bb874be8a510d54e91a37797b0c71b1160 (patch)
tree3e96acdd508c3c621935b6ef9bb5536c7712d44b /src
parentb2b95cad20846bb3235787c266c1723acf38f971 (diff)
downloadmpd-543a58bb874be8a510d54e91a37797b0c71b1160.tar.gz
mpd-543a58bb874be8a510d54e91a37797b0c71b1160.tar.xz
mpd-543a58bb874be8a510d54e91a37797b0c71b1160.zip
DecoderBuffer: implement _skip() using decoder_skip()
Diffstat (limited to 'src')
-rw-r--r--src/decoder/DecoderBuffer.cxx25
1 files changed, 8 insertions, 17 deletions
diff --git a/src/decoder/DecoderBuffer.cxx b/src/decoder/DecoderBuffer.cxx
index e26a702b7..7902e6e89 100644
--- a/src/decoder/DecoderBuffer.cxx
+++ b/src/decoder/DecoderBuffer.cxx
@@ -165,23 +165,14 @@ decoder_buffer_consume(DecoderBuffer *buffer, size_t nbytes)
bool
decoder_buffer_skip(DecoderBuffer *buffer, size_t nbytes)
{
- bool success;
+ const size_t available = decoder_buffer_available(buffer);
+ if (available >= nbytes) {
+ decoder_buffer_consume(buffer, nbytes);
+ return true;
+ }
- /* this could probably be optimized by seeking */
+ decoder_buffer_clear(buffer);
+ nbytes -= available;
- while (true) {
- auto data = decoder_buffer_read(buffer);
- if (!data.IsEmpty()) {
- if (data.size > nbytes)
- data.size = nbytes;
- decoder_buffer_consume(buffer, data.size);
- nbytes -= data.size;
- if (nbytes == 0)
- return true;
- }
-
- success = decoder_buffer_fill(buffer);
- if (!success)
- return false;
- }
+ return decoder_skip(buffer->decoder, *buffer->is, nbytes);
}