Browse code

2nd try to fix av_log() repeated detection

Originally committed as revision 25174 to svn://svn.ffmpeg.org/ffmpeg/trunk

Michael Niedermayer authored on 2010/09/25 00:37:01
Showing 4 changed files
... ...
@@ -13,6 +13,11 @@ libavutil:   2009-03-08
13 13
 
14 14
 API changes, most recent first:
15 15
 
16
+2010-09-24 - r25174 - lavu 50.28.0 - av_log_set_flags()
17
+  Default of av_log() changed due to many problems to the old no repeat
18
+  detection. Read the docs of AV_LOG_SKIP_REPEATED in log.h before
19
+  enabling it for your app!.
20
+
16 21
 2010-09-24 - r25167 - lavc 52.90.0 - av_opt_show2()
17 22
   Deprecate av_opt_show() in favor or av_opt_show2().
18 23
 
... ...
@@ -40,7 +40,7 @@
40 40
 #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c)
41 41
 
42 42
 #define LIBAVUTIL_VERSION_MAJOR 50
43
-#define LIBAVUTIL_VERSION_MINOR 27
43
+#define LIBAVUTIL_VERSION_MINOR 28
44 44
 #define LIBAVUTIL_VERSION_MICRO  0
45 45
 
46 46
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
... ...
@@ -33,6 +33,7 @@
33 33
 static
34 34
 #endif
35 35
 int av_log_level = AV_LOG_INFO;
36
+static int flags;
36 37
 
37 38
 #if defined(_WIN32) && !defined(__MINGW32CE__)
38 39
 #include <windows.h>
... ...
@@ -109,8 +110,9 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
109 109
     if(!detect_repeats) detect_repeats= isatty(2) ? 1 : -1;
110 110
 #endif
111 111
 
112
-    if(print_prefix && detect_repeats==1 && !strcmp(line, prev)){
112
+    if(print_prefix && (flags & AV_LOG_SKIP_REPEATED) && !strcmp(line, prev)){
113 113
         count++;
114
+        if(detect_repeats==1)
114 115
         fprintf(stderr, "    Last message repeated %d times\r", count);
115 116
         return;
116 117
     }
... ...
@@ -150,6 +152,11 @@ void av_log_set_level(int level)
150 150
     av_log_level = level;
151 151
 }
152 152
 
153
+void av_log_set_flags(int arg)
154
+{
155
+    flags= arg;
156
+}
157
+
153 158
 void av_log_set_callback(void (*callback)(void*, int, const char*, va_list))
154 159
 {
155 160
     av_log_callback = callback;
... ...
@@ -135,4 +135,15 @@ void av_log_set_callback(void (*)(void*, int, const char*, va_list));
135 135
 void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl);
136 136
 const char* av_default_item_name(void* ctx);
137 137
 
138
+/**
139
+ * Skip repeated messages, this requires the user app to use av_log() instead of
140
+ * (f)printf as the 2 would otherwise interfere and lead to
141
+ * "Last message repeated x times" messages below (f)printf messages with some
142
+ * bad luck.
143
+ * Also to receive the last, "last repeated" line if any, the user app must
144
+ * call av_log(NULL, AV_LOG_QUIET, ""); at the end
145
+ */
146
+#define AV_LOG_SKIP_REPEATED 1
147
+void av_log_set_flags(int arg);
148
+
138 149
 #endif /* AVUTIL_LOG_H */