"break" is so much easier than "eof=1; continue;", when "!eof" is the
loop condition.
---

 src/inputPlugins/aac_plugin.c |   13 ++++---------
 src/inputPlugins/mp4_plugin.c |   15 +++++----------
 2 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/src/inputPlugins/aac_plugin.c b/src/inputPlugins/aac_plugin.c
index f2d1510..c844525 100644
--- a/src/inputPlugins/aac_plugin.c
+++ b/src/inputPlugins/aac_plugin.c
@@ -289,7 +289,6 @@ static int aac_decode(struct decoder * mpd_decoder, char 
*path)
        AudioFormat audio_format;
        uint32_t sampleRate;
        unsigned char channels;
-       int eof = 0;
        unsigned int sampleCount;
        char *sampleBuffer;
        size_t sampleBufferLen;
@@ -342,13 +341,12 @@ static int aac_decode(struct decoder * mpd_decoder, char 
*path)
 
        advanceAacBuffer(&b, bread);
 
-       while (!eof) {
+       while (1) {
                fillAacBuffer(&b);
 
-               if (b.bytesIntoBuffer == 0) {
-                       eof = 1;
+               if (b.bytesIntoBuffer == 0)
                        break;
-               }
+
 #ifdef HAVE_FAAD_BUFLEN_FUNCS
                sampleBuffer = faacDecDecode(decoder, &frameInfo, b.buffer,
                                             b.bytesIntoBuffer);
@@ -360,7 +358,6 @@ static int aac_decode(struct decoder * mpd_decoder, char 
*path)
                        ERROR("error decoding AAC file: %s\n", path);
                        ERROR("faad2 error: %s\n",
                              faacDecGetErrorMessage(frameInfo.error));
-                       eof = 1;
                        break;
                }
 #ifdef HAVE_FAACDECFRAMEINFO_SAMPLERATE
@@ -395,10 +392,8 @@ static int aac_decode(struct decoder * mpd_decoder, char 
*path)
                if (dc.command == DECODE_COMMAND_SEEK) {
                        dc.seekError = 1;
                        dc_command_finished();
-               } else if (dc.command == DECODE_COMMAND_STOP) {
-                       eof = 1;
+               } else if (dc.command == DECODE_COMMAND_STOP)
                        break;
-               }
        }
 
        decoder_flush(mpd_decoder);
diff --git a/src/inputPlugins/mp4_plugin.c b/src/inputPlugins/mp4_plugin.c
index ac681a0..4ffe465 100644
--- a/src/inputPlugins/mp4_plugin.c
+++ b/src/inputPlugins/mp4_plugin.c
@@ -95,7 +95,6 @@ static int mp4_decode(struct decoder * mpd_decoder, 
InputStream * inStream)
        unsigned char channels;
        long sampleId;
        long numSamples;
-       int eof = 0;
        long dur;
        unsigned int sampleCount;
        char *sampleBuffer;
@@ -178,7 +177,7 @@ static int mp4_decode(struct decoder * mpd_decoder, 
InputStream * inStream)
 
        seekTable = xmalloc(sizeof(float) * numSamples);
 
-       for (sampleId = 0; sampleId < numSamples && !eof; sampleId++) {
+       for (sampleId = 0; sampleId < numSamples; sampleId++) {
                if (dc.command == DECODE_COMMAND_SEEK)
                        seeking = 1;
 
@@ -221,10 +220,9 @@ static int mp4_decode(struct decoder * mpd_decoder, 
InputStream * inStream)
                        continue;
 
                if (mp4ff_read_sample(mp4fh, track, sampleId, &mp4Buffer,
-                                     &mp4BufferSize) == 0) {
-                       eof = 1;
-                       continue;
-               }
+                                     &mp4BufferSize) == 0)
+                       break;
+
 #ifdef HAVE_FAAD_BUFLEN_FUNCS
                sampleBuffer = faacDecDecode(decoder, &frameInfo, mp4Buffer,
                                             mp4BufferSize);
@@ -237,7 +235,6 @@ static int mp4_decode(struct decoder * mpd_decoder, 
InputStream * inStream)
                if (frameInfo.error > 0) {
                        ERROR("faad2 error: %s\n",
                              faacDecGetErrorMessage(frameInfo.error));
-                       eof = 1;
                        break;
                }
 
@@ -273,10 +270,8 @@ static int mp4_decode(struct decoder * mpd_decoder, 
InputStream * inStream)
                decoder_data(mpd_decoder, inStream, 1, sampleBuffer,
                             sampleBufferLen, file_time,
                             bitRate, NULL);
-               if (dc.command == DECODE_COMMAND_STOP) {
-                       eof = 1;
+               if (dc.command == DECODE_COMMAND_STOP)
                        break;
-               }
        }
 
        free(seekTable);


-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to