diff options
author | Max Kellermann <max@duempel.org> | 2014-04-10 13:49:20 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-04-10 13:49:20 +0200 |
commit | 1c02b4b9f4147521d466e14784c5f3cc14b7f6a9 (patch) | |
tree | 27bd7c746a3f0dbe80d24a157e9225491bd3d280 /src/decoder/plugins/SndfileDecoderPlugin.cxx | |
parent | afdefefbe4b39ddcca8b9fedd37cafdc949cc3d5 (diff) | |
parent | d0119548c116ae038b1a1f625f11c4815d3a4bd8 (diff) | |
download | mpd-1c02b4b9f4147521d466e14784c5f3cc14b7f6a9.tar.gz mpd-1c02b4b9f4147521d466e14784c5f3cc14b7f6a9.tar.xz mpd-1c02b4b9f4147521d466e14784c5f3cc14b7f6a9.zip |
Merge tag 'release-0.18.10'
Diffstat (limited to 'src/decoder/plugins/SndfileDecoderPlugin.cxx')
-rw-r--r-- | src/decoder/plugins/SndfileDecoderPlugin.cxx | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/decoder/plugins/SndfileDecoderPlugin.cxx b/src/decoder/plugins/SndfileDecoderPlugin.cxx index 72ea77d15..6d9e0d31e 100644 --- a/src/decoder/plugins/SndfileDecoderPlugin.cxx +++ b/src/decoder/plugins/SndfileDecoderPlugin.cxx @@ -56,14 +56,28 @@ sndfile_vio_read(void *ptr, sf_count_t count, void *user_data) { InputStream &is = *(InputStream *)user_data; + sf_count_t total_bytes = 0; Error error; - size_t nbytes = is.LockRead(ptr, count, error); - if (nbytes == 0 && error.IsDefined()) { - LogError(error); - return -1; - } - return nbytes; + /* this loop is necessary because libsndfile chokes on partial + reads */ + + do { + size_t nbytes = is.LockRead((char *)ptr + total_bytes, + count - total_bytes, error); + if (nbytes == 0) { + if (error.IsDefined()) { + LogError(error); + return -1; + } + + break; + } + + total_bytes += nbytes; + } while (total_bytes < count); + + return total_bytes; } static sf_count_t |