sad

simple audio daemon
git clone git://git.2f30.org/sad
Log | Files | Refs | LICENSE

commit 82a7323f30384ab30b498ac307677100f034cf28
parent 1cb84b2d8d7906af9666450375a9a799dd62846e
Author: sin <sin@2f30.org>
Date:   Fri, 26 Dec 2014 18:33:07 +0000

Fill the entire buffer

Diffstat:
Mvorbis.c | 25++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/vorbis.c b/vorbis.c @@ -49,15 +49,22 @@ err0: static int vorbisdecode(void *buf, int nbytes) { - int r; - - r = ov_read(&vf, buf, nbytes, 0, 2, 1, &cursect); - if (r < 0) { - warnx("ov_read: failed"); - return -1; - } else if (r == 0) - return r; - return r; + int r, decoded; + char *p = buf; + + decoded = 0; + while (nbytes > 0) { + r = ov_read(&vf, &p[decoded], nbytes, 0, 2, 1, &cursect); + if (r < 0) { + warnx("ov_read: failed"); + return -1; + } else if (r == 0) { + break; + } + decoded += r; + nbytes -= r; + } + return decoded; } static int