- //PARA_DEBUG_LOG("vorbis requests %zu x %zu = %zu bytes\n", size, nmemb, size * nmemb);
- copied = 0;
- for (;;) {
- char *btr_buf;
- size_t nbytes = btr_next_buffer(btrn, &btr_buf);
- if (nbytes == 0)
- break;
- nbytes = PARA_MIN(nmemb - copied, nbytes);
- memcpy(buf + copied, btr_buf, nbytes);
- copied += nbytes;
- btr_consume(btrn, nbytes);
- if (copied == nmemb)
- break;
- }
- return copied;
+ assert(pod->converted <= nbytes);
+ tmp = nbytes - pod->converted;
+ PARA_DEBUG_LOG("vorbis requests %zu bytes have %zu\n", nmemb, tmp);
+ tmp = PARA_MIN(tmp, nmemb);
+ if (tmp == 0)
+ return 0;
+ memcpy(buf, btr_buf + pod->converted, tmp);
+ pod->converted += tmp;
+ return tmp;