[SCM] libav/experimental: 2nd try to fix av_log() repeated detection

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 17:16:06 UTC 2013


The following commit has been merged in the experimental branch:
commit 1c1c80f0a3157278bf66da98e194729cdeea6631
Author: Michael Niedermayer <michaelni at gmx.at>
Date:   Fri Sep 24 15:37:01 2010 +0000

    2nd try to fix av_log() repeated detection
    
    Originally committed as revision 25174 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/doc/APIchanges b/doc/APIchanges
index e835e70..9ccb75a 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,11 @@ libavutil:   2009-03-08
 
 API changes, most recent first:
 
+2010-09-24 - r25174 - lavu 50.28.0 - av_log_set_flags()
+  Default of av_log() changed due to many problems to the old no repeat
+  detection. Read the docs of AV_LOG_SKIP_REPEATED in log.h before
+  enabling it for your app!.
+
 2010-09-24 - r25167 - lavc 52.90.0 - av_opt_show2()
   Deprecate av_opt_show() in favor or av_opt_show2().
 
diff --git a/libavutil/avutil.h b/libavutil/avutil.h
index 0b0b4ce..758b012 100644
--- a/libavutil/avutil.h
+++ b/libavutil/avutil.h
@@ -40,7 +40,7 @@
 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
 
 #define LIBAVUTIL_VERSION_MAJOR 50
-#define LIBAVUTIL_VERSION_MINOR 27
+#define LIBAVUTIL_VERSION_MINOR 28
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
diff --git a/libavutil/log.c b/libavutil/log.c
index 2e95068..ec16c67 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -33,6 +33,7 @@
 static
 #endif
 int av_log_level = AV_LOG_INFO;
+static int flags;
 
 #if defined(_WIN32) && !defined(__MINGW32CE__)
 #include <windows.h>
@@ -109,8 +110,9 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
     if(!detect_repeats) detect_repeats= isatty(2) ? 1 : -1;
 #endif
 
-    if(print_prefix && detect_repeats==1 && !strcmp(line, prev)){
+    if(print_prefix && (flags & AV_LOG_SKIP_REPEATED) && !strcmp(line, prev)){
         count++;
+        if(detect_repeats==1)
         fprintf(stderr, "    Last message repeated %d times\r", count);
         return;
     }
@@ -150,6 +152,11 @@ void av_log_set_level(int level)
     av_log_level = level;
 }
 
+void av_log_set_flags(int arg)
+{
+    flags= arg;
+}
+
 void av_log_set_callback(void (*callback)(void*, int, const char*, va_list))
 {
     av_log_callback = callback;
diff --git a/libavutil/log.h b/libavutil/log.h
index 831c26e..3b364be 100644
--- a/libavutil/log.h
+++ b/libavutil/log.h
@@ -135,4 +135,15 @@ void av_log_set_callback(void (*)(void*, int, const char*, va_list));
 void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl);
 const char* av_default_item_name(void* ctx);
 
+/**
+ * Skip repeated messages, this requires the user app to use av_log() instead of
+ * (f)printf as the 2 would otherwise interfere and lead to
+ * "Last message repeated x times" messages below (f)printf messages with some
+ * bad luck.
+ * Also to receive the last, "last repeated" line if any, the user app must
+ * call av_log(NULL, AV_LOG_QUIET, ""); at the end
+ */
+#define AV_LOG_SKIP_REPEATED 1
+void av_log_set_flags(int arg);
+
 #endif /* AVUTIL_LOG_H */

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list