shithub: aacdec

Download patch

ref: ca0f0a41b215eb0bc74602dc0da151042f74c0fb
parent: f007cb73f33286454e881969a377c7f1d90201c5
author: menno <menno>
date: Tue Jan 15 08:20:13 EST 2002

Oops, forgot to check for errors in MP4 file decoding

--- a/frontend/main.c
+++ b/frontend/main.c
@@ -16,7 +16,7 @@
 ** along with this program; if not, write to the Free Software 
 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 **
-** $Id: main.c,v 1.2 2002/01/15 12:58:38 menno Exp $
+** $Id: main.c,v 1.3 2002/01/15 13:20:13 menno Exp $
 **/
 
 #ifdef _WIN32
@@ -411,12 +411,6 @@
 
         sample_buffer = faacDecDecode(hDecoder, &frameInfo, buffer);
 
-        if (frameInfo.error > 0)
-        {
-            fprintf(stderr, "Error: %s\n",
-                faacDecGetErrorMessage(frameInfo.error));
-        }
-
         percent = min((int)(sampleId*100)/numSamples, 100);
         if (percent > old_percent)
         {
@@ -452,6 +446,16 @@
         if ((frameInfo.error == 0) && (frameInfo.samples > 0))
         {
             write_audio_file(aufile, sample_buffer, frameInfo.samples);
+        }
+
+        if (frameInfo.error > 0)
+        {
+            fprintf(stderr, "Error: %s\n",
+                faacDecGetErrorMessage(frameInfo.error));
+            faacDecClose(hDecoder);
+            MP4Close(infile);
+            close_audio_file(aufile);
+            return frameInfo.error;
         }
     }