From 6c3064a4b50de7f123bf9d92db6303056281536c Mon Sep 17 00:00:00 2001 From: "Earle F. Philhower, III" Date: Fri, 22 Dec 2017 21:18:01 -0800 Subject: [PATCH] Remove infinite loop on error in DecodeNextFrame DecodeNextFrame had a leftover while(1) in the inner loop without any additional Input() calls, which could lead to an infinite loop on an error condition. Remove that unneeded loop. Addresses some of the stuff found in issue #21 --- src/AudioGeneratorMP3.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/AudioGeneratorMP3.cpp b/src/AudioGeneratorMP3.cpp index 9e987ca..07d6d49 100644 --- a/src/AudioGeneratorMP3.cpp +++ b/src/AudioGeneratorMP3.cpp @@ -111,15 +111,13 @@ enum mad_flow AudioGeneratorMP3::Input() bool AudioGeneratorMP3::DecodeNextFrame() { do { - while (1) { - if (mad_frame_decode(&frame, &stream) == -1) { - if (!MAD_RECOVERABLE(stream.error)) break; - ErrorToFlow(); // Always returns CONTINUE - continue; - } - nsCountMax = MAD_NSBSAMPLES(&frame.header); - return true; + if (mad_frame_decode(&frame, &stream) == -1) { + if (!MAD_RECOVERABLE(stream.error)) break; + ErrorToFlow(); // Always returns CONTINUE + continue; } + nsCountMax = MAD_NSBSAMPLES(&frame.header); + return true; } while (stream.error == MAD_ERROR_BUFLEN); Serial.printf_P(PSTR("stream.error != mad_Err_bufflen\n")); return false;