diff options
author | Max Kellermann <max@duempel.org> | 2014-07-09 19:29:34 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-07-09 19:42:36 +0200 |
commit | 552af5455eccdea2b43d202fab3f6a8c637137a8 (patch) | |
tree | 993b1a90819ba65586787d5cdf33dc3d02c20b58 /src/decoder/plugins/DsdLib.cxx | |
parent | 8759bc1b41abea5472a69f2803be7194f8612e79 (diff) | |
download | mpd-552af5455eccdea2b43d202fab3f6a8c637137a8.tar.gz mpd-552af5455eccdea2b43d202fab3f6a8c637137a8.tar.xz mpd-552af5455eccdea2b43d202fab3f6a8c637137a8.zip |
decoder/dsdlib: use decoder_skip()
Reduce duplicate code.
Diffstat (limited to '')
-rw-r--r-- | src/decoder/plugins/DsdLib.cxx | 32 |
1 files changed, 6 insertions, 26 deletions
diff --git a/src/decoder/plugins/DsdLib.cxx b/src/decoder/plugins/DsdLib.cxx index 03160deaa..c52c504e6 100644 --- a/src/decoder/plugins/DsdLib.cxx +++ b/src/decoder/plugins/DsdLib.cxx @@ -66,19 +66,7 @@ dsdlib_skip_to(Decoder *decoder, InputStream &is, if (uint64_t(is.GetOffset()) > offset) return false; - char buffer[8192]; - while (uint64_t(is.GetOffset()) < offset) { - size_t length = sizeof(buffer); - if (offset - is.GetOffset() < (uint64_t)length) - length = offset - is.GetOffset(); - - size_t nbytes = decoder_read(decoder, is, buffer, length); - if (nbytes == 0) - return false; - } - - assert(uint64_t(is.GetOffset()) == offset); - return true; + return dsdlib_skip(decoder, is, offset - is.GetOffset()); } /** @@ -94,20 +82,12 @@ dsdlib_skip(Decoder *decoder, InputStream &is, if (is.IsSeekable()) return is.Seek(is.GetOffset() + delta, IgnoreError()); - char buffer[8192]; - while (delta > 0) { - size_t length = sizeof(buffer); - if ((uint64_t)length > delta) - length = delta; - - size_t nbytes = decoder_read(decoder, is, buffer, length); - if (nbytes == 0) - return false; - - delta -= nbytes; - } + if (delta > 1024 * 1024) + /* don't skip more than one megabyte; it would be too + expensive */ + return false; - return true; + return decoder_skip(decoder, is, delta); } #ifdef HAVE_ID3TAG |