return 0;
}
-static size_t used_mad_buffer_bytes(struct mad_stream *s, size_t max)
+static void mp3dec_consume(struct btr_node *btrn, struct mad_stream *s,
+ size_t max)
{
- size_t rv;
+ size_t used;
if (!s->next_frame)
- return max;
- /* we still have some data */
- rv = s->next_frame - s->buffer;
- assert(rv <= max);
- return rv;
+ used = max;
+ else { /* we still have some data */
+ used = s->next_frame - s->buffer;
+ assert(used <= max);
+ }
+ btr_consume(btrn, used);
}
static void mp3dec_close(struct filter_node *fn)
int i, ret;
struct private_mp3dec_data *pmd = fn->private_data;
struct btr_node *btrn = fn->btrn;
- size_t loaded = 0, used, len, iqs;
+ size_t loaded = 0, len, iqs;
char *inbuffer, *outbuffer;
next_buffer:
next_frame:
ret = mad_header_decode(&pmd->frame.header, &pmd->stream);
if (ret < 0) {
- used = used_mad_buffer_bytes(&pmd->stream, len);
- btr_consume(btrn, used);
+ mp3dec_consume(btrn, &pmd->stream, len);
if (pmd->stream.error == MAD_ERROR_BUFLEN) {
if (len == iqs && btr_no_parent(btrn)) {
ret = -E_MP3DEC_EOF;
ret = -E_MP3DEC_CORRUPT;
if (fn->min_iqs > MP3DEC_MAX_FRAME)
goto err;
+ mp3dec_consume(btrn, &pmd->stream, len);
return;
}
if (pmd->stream.error != MAD_ERROR_BADDATAPTR)
goto decode;
- used = used_mad_buffer_bytes(&pmd->stream, len);
- btr_consume(btrn, used);
+ mp3dec_consume(btrn, &pmd->stream, len);
return;
}
fn->min_iqs = 0;