aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-08-26 08:27:10 +0200
committerEric Wong <normalperson@yhbt.net>2008-08-30 18:44:56 -0700
commit7b47338ca996f8fda1bd0f8c743555a25409c200 (patch)
tree860c9f8dc05e483556683b444680f98541de8c34 /src
parentd1015501dffd383b9ab9428303999615fde0fc66 (diff)
downloadmpd-7b47338ca996f8fda1bd0f8c743555a25409c200.tar.gz
mpd-7b47338ca996f8fda1bd0f8c743555a25409c200.tar.xz
mpd-7b47338ca996f8fda1bd0f8c743555a25409c200.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/inputPlugins/aac_plugin.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/inputPlugins/aac_plugin.c b/src/inputPlugins/aac_plugin.c
index de611b1ce..15a7da0ef 100644
--- a/src/inputPlugins/aac_plugin.c
+++ b/src/inputPlugins/aac_plugin.c
@@ -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) ||