Commit 95ac6071 authored by Marcello Desantis's avatar Marcello Desantis Committed by Max Kellermann

decoder/sndfile: work around libsndfile bug on partial read

parent 3a4e6670
......@@ -3,6 +3,7 @@ ver 0.18.10 (not yet released)
- ffmpeg: fix seeking bug
- ffmpeg: handle unknown stream start time
- gme: fix memory leak
- sndfile: work around libsndfile bug on partial read
* don't interrupt playback when current song gets deleted
ver 0.18.9 (2014/03/02)
......
......@@ -55,14 +55,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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment