Commit eedbd28e authored by Max Kellermann's avatar Max Kellermann

wavpack: read_bytes() should not return after partial reads

libwavpack expects the read_bytes() stream method to fill the whole buffer, and fails badly when we return a partial read (i.e. not enough data available yet). This caused wavpack streams to break. Re-implement the buffer filling loop.
parent 010a27cd
......@@ -348,7 +348,22 @@ static int32_t read_bytes(void *id, void *data, int32_t bcount)
--bcount;
++i;
}
return i + decoder_read(isp->decoder, isp->is, buf, bcount);
/* wavpack fails if we return a partial read, so we just wait
until the buffer is full */
while (bcount > 0) {
size_t nbytes = decoder_read(isp->decoder, isp->is,
buf, bcount);
if (nbytes == 0)
/* EOF, error or a decoder command */
break;
i += nbytes;
bcount -= nbytes;
buf += nbytes;
}
return i;
}
static uint32_t get_pos(void *id)
......
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