cosmetics
[paraslash.git] / aacdec.c
index e1841d9873df77135f6a9963974cdc9b194aeea4..edbe2637521f59bc1f7403bf06e110a7a85d15df 100644 (file)
--- a/aacdec.c
+++ b/aacdec.c
@@ -34,6 +34,8 @@
 /** the output buffer size */
 #define AAC_OUTBUF_SIZE (32 * 1024)
 
 /** the output buffer size */
 #define AAC_OUTBUF_SIZE (32 * 1024)
 
+#define MAX_ERRORS 20
+
 /**
  * data specific to the aacdec filter
  *
 /**
  * data specific to the aacdec filter
  *
@@ -45,6 +47,7 @@ struct private_aacdec_data {
 
        int initialized;
        int decoder_length;
 
        int initialized;
        int decoder_length;
+       unsigned error_count;
        size_t consumed_total;
        size_t entry;
 };
        size_t consumed_total;
        size_t entry;
 };
@@ -119,8 +122,10 @@ static ssize_t aacdec(char *input_buffer, size_t len, struct filter_node *fn)
        p = inbuf + consumed;
        outbuffer = NeAACDecDecode(padd->handle, &padd->frame_info, p,
                len - consumed);
        p = inbuf + consumed;
        outbuffer = NeAACDecDecode(padd->handle, &padd->frame_info, p,
                len - consumed);
-       ret = -E_AAC_DECODE;
        if (padd->frame_info.error) {
        if (padd->frame_info.error) {
+               ret = -E_AAC_DECODE;
+               if (padd->error_count++ > MAX_ERRORS)
+                       goto out;
                PARA_ERROR_LOG("frame_error: %d, consumed: %zu + %zd + %lu\n",
                        padd->frame_info.error, padd->consumed_total,
                        consumed, padd->frame_info.bytesconsumed);
                PARA_ERROR_LOG("frame_error: %d, consumed: %zu + %zd + %lu\n",
                        padd->frame_info.error, padd->consumed_total,
                        consumed, padd->frame_info.bytesconsumed);
@@ -129,6 +134,7 @@ static ssize_t aacdec(char *input_buffer, size_t len, struct filter_node *fn)
                consumed++; /* catch 21 */
                goto success;
        }
                consumed++; /* catch 21 */
                goto success;
        }
+       padd->error_count = 0;
        consumed += padd->frame_info.bytesconsumed;
        ret = consumed;
        if (!padd->frame_info.samples)
        consumed += padd->frame_info.bytesconsumed;
        ret = consumed;
        if (!padd->frame_info.samples)