aac: shift the input buffer before the full check

When the buffer was full, but everything was already consumed,
fillAacBuffer() would not attempt to flush and refill it.
This commit is contained in:
Max Kellermann 2008-11-12 08:32:21 +01:00
parent 432da18e44
commit b67a8e4d6e

View File

@ -53,13 +53,14 @@ static void fillAacBuffer(AacBuffer * b)
{
size_t rest, bread;
if (b->bytesIntoBuffer >= sizeof(b->buffer))
if (b->bytesConsumed > 0)
aac_buffer_shift(b, b->bytesConsumed);
rest = sizeof(b->buffer) - b->bytesIntoBuffer;
if (rest == 0)
/* buffer already full */
return;
aac_buffer_shift(b, b->bytesConsumed);
rest = sizeof(b->buffer) - b->bytesIntoBuffer;
bread = decoder_read(b->decoder, b->inStream,
(void *)(b->buffer + b->bytesIntoBuffer),
rest);