Commit 2a141411 authored by Max Kellermann's avatar Max Kellermann

aac: simplified fillAacBuffer()

Return instead of putting all the code into a if-closure. That saves one level of indentation.
parent 1d18f008
...@@ -39,43 +39,35 @@ typedef struct { ...@@ -39,43 +39,35 @@ typedef struct {
static void fillAacBuffer(AacBuffer * b) static void fillAacBuffer(AacBuffer * b)
{ {
if (b->bytesConsumed > 0) { size_t bread;
size_t bread;
if (b->bytesIntoBuffer) {
memmove((void *)b->buffer, (void *)(b->buffer +
b->bytesConsumed),
b->bytesIntoBuffer);
}
if (!b->atEof) { if (b->bytesConsumed == 0)
bread = readFromInputStream(b->inStream, return;
(void *)(b->buffer +
b->
bytesIntoBuffer),
1, b->bytesConsumed);
if (bread != b->bytesConsumed)
b->atEof = 1;
b->bytesIntoBuffer += bread;
}
b->bytesConsumed = 0; if (b->bytesIntoBuffer) {
memmove((void *)b->buffer, (void *)(b->buffer +
b->bytesConsumed),
b->bytesIntoBuffer);
}
if (b->bytesIntoBuffer > 3) { if (!b->atEof) {
if (memcmp(b->buffer, "TAG", 3) == 0) bread = readFromInputStream(b->inStream,
b->bytesIntoBuffer = 0; (void *)(b->buffer +
} b->
if (b->bytesIntoBuffer > 11) { bytesIntoBuffer),
if (memcmp(b->buffer, "LYRICSBEGIN", 11) == 0) { 1, b->bytesConsumed);
b->bytesIntoBuffer = 0; if (bread != b->bytesConsumed)
} b->atEof = 1;
} b->bytesIntoBuffer += bread;
if (b->bytesIntoBuffer > 8) {
if (memcmp(b->buffer, "APETAGEX", 8) == 0) {
b->bytesIntoBuffer = 0;
}
}
} }
b->bytesConsumed = 0;
if ((b->bytesIntoBuffer > 3 && memcmp(b->buffer, "TAG", 3) == 0) ||
(b->bytesIntoBuffer > 11 &&
memcmp(b->buffer, "LYRICSBEGIN", 11) == 0) ||
(b->bytesIntoBuffer > 8 && memcmp(b->buffer, "APETAGEX", 8) == 0))
b->bytesIntoBuffer = 0;
} }
static void advanceAacBuffer(AacBuffer * b, size_t bytes) static void advanceAacBuffer(AacBuffer * b, size_t bytes)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment