aac: don't depend on consumed data in fillAacBuffer()

Fill the AacBuffer even when nothing has been consumed yet.  The
function should not check for consumed data, but for free space at the
end of the buffer.
This commit is contained in:
Max Kellermann 2008-08-26 08:27:10 +02:00
parent 2a14141121
commit 35858dfe3a

View File

@ -41,28 +41,32 @@ static void fillAacBuffer(AacBuffer * b)
{
size_t bread;
if (b->bytesConsumed == 0)
if (b->bytesIntoBuffer >= FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS)
/* buffer already full */
return;
if (b->bytesIntoBuffer) {
if (b->bytesConsumed > 0 && b->bytesIntoBuffer > 0) {
memmove((void *)b->buffer, (void *)(b->buffer +
b->bytesConsumed),
b->bytesIntoBuffer);
}
b->bytesConsumed = 0;
if (!b->atEof) {
size_t rest = FAAD_MIN_STREAMSIZE * AAC_MAX_CHANNELS -
b->bytesIntoBuffer;
bread = readFromInputStream(b->inStream,
(void *)(b->buffer +
b->
bytesIntoBuffer),
1, b->bytesConsumed);
if (bread != b->bytesConsumed)
1, rest);
if (bread != rest)
b->atEof = 1;
b->bytesIntoBuffer += bread;
}
b->bytesConsumed = 0;
if ((b->bytesIntoBuffer > 3 && memcmp(b->buffer, "TAG", 3) == 0) ||
(b->bytesIntoBuffer > 11 &&
memcmp(b->buffer, "LYRICSBEGIN", 11) == 0) ||