aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins
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:54 -0700
commitd1015501dffd383b9ab9428303999615fde0fc66 (patch)
treee5097437fe15a357f31485ac67aaec8860b9fcb1 /src/inputPlugins
parent15e76670b40a223ee58c5aae26b2d9540a1b87b8 (diff)
downloadmpd-d1015501dffd383b9ab9428303999615fde0fc66.tar.gz
mpd-d1015501dffd383b9ab9428303999615fde0fc66.tar.xz
mpd-d1015501dffd383b9ab9428303999615fde0fc66.zip
aac: simplified fillAacBuffer()
Return instead of putting all the code into a if-closure. That saves one level of indentation.
Diffstat (limited to 'src/inputPlugins')
-rw-r--r--src/inputPlugins/aac_plugin.c58
1 files changed, 25 insertions, 33 deletions
diff --git a/src/inputPlugins/aac_plugin.c b/src/inputPlugins/aac_plugin.c
index 353fafd40..de611b1ce 100644
--- a/src/inputPlugins/aac_plugin.c
+++ b/src/inputPlugins/aac_plugin.c
@@ -39,43 +39,35 @@ typedef struct {
static void fillAacBuffer(AacBuffer * b)
{
- if (b->bytesConsumed > 0) {
- size_t bread;
-
- if (b->bytesIntoBuffer) {
- memmove((void *)b->buffer, (void *)(b->buffer +
- b->bytesConsumed),
- b->bytesIntoBuffer);
- }
+ size_t bread;
- if (!b->atEof) {
- bread = readFromInputStream(b->inStream,
- (void *)(b->buffer +
- b->
- bytesIntoBuffer),
- 1, b->bytesConsumed);
- if (bread != b->bytesConsumed)
- b->atEof = 1;
- b->bytesIntoBuffer += bread;
- }
+ if (b->bytesConsumed == 0)
+ return;
- b->bytesConsumed = 0;
+ if (b->bytesIntoBuffer) {
+ memmove((void *)b->buffer, (void *)(b->buffer +
+ b->bytesConsumed),
+ b->bytesIntoBuffer);
+ }
- if (b->bytesIntoBuffer > 3) {
- if (memcmp(b->buffer, "TAG", 3) == 0)
- b->bytesIntoBuffer = 0;
- }
- if (b->bytesIntoBuffer > 11) {
- if (memcmp(b->buffer, "LYRICSBEGIN", 11) == 0) {
- b->bytesIntoBuffer = 0;
- }
- }
- if (b->bytesIntoBuffer > 8) {
- if (memcmp(b->buffer, "APETAGEX", 8) == 0) {
- b->bytesIntoBuffer = 0;
- }
- }
+ if (!b->atEof) {
+ bread = readFromInputStream(b->inStream,
+ (void *)(b->buffer +
+ b->
+ bytesIntoBuffer),
+ 1, b->bytesConsumed);
+ if (bread != b->bytesConsumed)
+ 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) ||
+ (b->bytesIntoBuffer > 8 && memcmp(b->buffer, "APETAGEX", 8) == 0))
+ b->bytesIntoBuffer = 0;
}
static void advanceAacBuffer(AacBuffer * b, size_t bytes)