[FFmpeg-devel] [PATCH 1/3] avutil/log: add AV_LOG_ASYNC
Michael Niedermayer
michaelni at gmx.at
Thu Mar 20 03:57:57 CET 2014
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
libavutil/log.c | 7 +++++--
libavutil/log.h | 6 ++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/libavutil/log.c b/libavutil/log.c
index a0bb5e4..e40ffa4 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -247,11 +247,13 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
char line[LINE_SZ];
static int is_atty;
int type[2];
+ int use_lock = !(flags & AV_LOG_ASYNC);
if (level > av_log_level)
return;
#if HAVE_PTHREADS
- pthread_mutex_lock(&mutex);
+ if (use_lock)
+ pthread_mutex_lock(&mutex);
#endif
format_line(ptr, level, fmt, vl, part, &print_prefix, type);
@@ -283,7 +285,8 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
end:
av_bprint_finalize(part+2, NULL);
#if HAVE_PTHREADS
- pthread_mutex_unlock(&mutex);
+ if (use_lock)
+ pthread_mutex_unlock(&mutex);
#endif
}
diff --git a/libavutil/log.h b/libavutil/log.h
index f16e382..b8ea759 100644
--- a/libavutil/log.h
+++ b/libavutil/log.h
@@ -311,6 +311,12 @@ void av_log_format_line(void *ptr, int level, const char *fmt, va_list vl,
* call av_log(NULL, AV_LOG_QUIET, "%s", ""); at the end
*/
#define AV_LOG_SKIP_REPEATED 1
+/**
+ * Do not thread synchronization.
+ * This allows av_log() to be used from a signal handler but may lead to
+ * garbled output.
+ */
+#define AV_LOG_ASYNC 0x1000
void av_log_set_flags(int arg);
/**
--
1.7.9.5
More information about the ffmpeg-devel
mailing list