* length of the file (!) */
pos += framelen;
framelen = sbc_decode(&sbc, stream + pos, streamlen - pos,
- buf + count, sizeof(buf) - count,
- &len);
+ buf + count, sizeof(buf) - count, &len);
}
if (count > 0) {
while (1) {
if (size < sizeof(input)) {
len = __read(fd, input + size, sizeof(input) - size);
- if (len == 0)
+ if (len == 0 && size == 0)
break;
if (len < 0) {
size += len;
}
- len = sbc_encode(&sbc, input, size, output, sizeof(output),
- &encoded);
+ len = sbc_encode(&sbc, input, size,
+ output, sizeof(output), &encoded);
if (len < size)
memmove(input, input + len, size - len);