[vlc-commits] packetizer: mpeg4audio: don't spam with warnings

Francois Cartegnie git at videolan.org
Sun Mar 15 22:03:52 CET 2015


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Fri Mar 13 21:02:45 2015 +0100| [123d2cdb1856e5d9f21332d7fa6293f97cfd1c1e] | committer: Francois Cartegnie

packetizer: mpeg4audio: don't spam with warnings

If frames have CRC, console is spammed.
CRC warning should happen only once.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=123d2cdb1856e5d9f21332d7fa6293f97cfd1c1e
---

 modules/packetizer/mpeg4audio.c |   20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/modules/packetizer/mpeg4audio.c b/modules/packetizer/mpeg4audio.c
index e17cac1..3b660fb 100644
--- a/modules/packetizer/mpeg4audio.c
+++ b/modules/packetizer/mpeg4audio.c
@@ -138,8 +138,23 @@ struct decoder_sys_t
     /* LOAS */
     bool b_latm_cfg;
     latm_mux_t latm;
+
+    int i_warnings;
 };
 
+enum
+{
+    WARN_CRC_UNSUPPORTED = 1
+};
+
+#define WARN_ONCE(warn, msg) do{\
+        if( (p_dec->p_sys->i_warnings & warn) == 0 )\
+        {\
+            p_dec->p_sys->i_warnings |= warn;\
+            msg_Warn( p_dec, msg );\
+        }\
+    } while(0)
+
 enum {
     TYPE_NONE,
     TYPE_RAW,
@@ -196,6 +211,7 @@ static int OpenPacketizer(vlc_object_t *p_this)
     date_Set(&p_sys->end_date, 0);
     block_BytestreamInit(&p_sys->bytestream);
     p_sys->b_latm_cfg = false;
+    p_sys->i_warnings = 0;
 
     /* Set output properties */
     p_dec->fmt_out.i_cat = AUDIO_ES;
@@ -351,7 +367,7 @@ static int ADTSSyncInfo(decoder_t * p_dec, const uint8_t * p_buf,
 
     if (i_raw_blocks_in_frame == 0) {
         if (b_crc) {
-            msg_Warn(p_dec, "ADTS CRC not supported");
+            WARN_ONCE(WARN_CRC_UNSUPPORTED, "ADTS CRC not supported");
             //uint16_t crc = (p_buf[7] << 8) | p_buf[8];
         }
     } else {
@@ -374,7 +390,7 @@ static int ADTSSyncInfo(decoder_t * p_dec, const uint8_t * p_buf,
         for (i = 0 ; i <= i_raw_blocks_in_frame ; i++) {
             //read 1 block
             if (b_crc) {
-                msg_Err(p_dec, "ADTS CRC not supported");
+                WARN_ONCE(WARN_CRC_UNSUPPORTED, "ADTS CRC not supported");
                 //uint16_t crc = (*p_pos << 8) | *(p_pos+1);
                 //p_pos += 2;
             }



More information about the vlc-commits mailing list