Message ID | 20180104041408.6268-2-jamrial@gmail.com |
---|---|
State | Accepted |
Commit | 8d9c9775b248b0a0f43bd96a242b5311fcc28b72 |
Headers | show |
On Thu, 4 Jan 2018 01:14:08 -0300 James Almer <jamrial@gmail.com> wrote: > w32threads and os2threads both support static mutex initialization now, > so don't limit it to pthreads only. > > Signed-off-by: James Almer <jamrial@gmail.com> > --- > libavutil/log.c | 14 ++++---------- > 1 file changed, 4 insertions(+), 10 deletions(-) > > diff --git a/libavutil/log.c b/libavutil/log.c > index 7a6dd936e5..bd47f2a25f 100644 > --- a/libavutil/log.c > +++ b/libavutil/log.c > @@ -39,11 +39,9 @@ > #include "common.h" > #include "internal.h" > #include "log.h" > +#include "thread.h" > > -#if HAVE_PTHREADS > -#include <pthread.h> > -static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; > -#endif > +static AVMutex mutex = AV_MUTEX_INITIALIZER; > > #define LINE_SZ 1024 > > @@ -317,9 +315,7 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) > > if (level > av_log_level) > return; > -#if HAVE_PTHREADS > - pthread_mutex_lock(&mutex); > -#endif > + ff_mutex_lock(&mutex); > > format_line(ptr, level, fmt, vl, part, &print_prefix, type); > snprintf(line, sizeof(line), "%s%s%s%s", part[0].str, part[1].str, part[2].str, part[3].str); > @@ -356,9 +352,7 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) > #endif > end: > av_bprint_finalize(part+3, NULL); > -#if HAVE_PTHREADS > - pthread_mutex_unlock(&mutex); > -#endif > + ff_mutex_unlock(&mutex); > } > > static void (*av_log_callback)(void*, int, const char*, va_list) = LGTM
On 1/4/2018 7:50 AM, wm4 wrote: > On Thu, 4 Jan 2018 01:14:08 -0300 > James Almer <jamrial@gmail.com> wrote: > >> w32threads and os2threads both support static mutex initialization now, >> so don't limit it to pthreads only. >> >> Signed-off-by: James Almer <jamrial@gmail.com> >> --- >> libavutil/log.c | 14 ++++---------- >> 1 file changed, 4 insertions(+), 10 deletions(-) >> >> diff --git a/libavutil/log.c b/libavutil/log.c >> index 7a6dd936e5..bd47f2a25f 100644 >> --- a/libavutil/log.c >> +++ b/libavutil/log.c >> @@ -39,11 +39,9 @@ >> #include "common.h" >> #include "internal.h" >> #include "log.h" >> +#include "thread.h" >> >> -#if HAVE_PTHREADS >> -#include <pthread.h> >> -static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; >> -#endif >> +static AVMutex mutex = AV_MUTEX_INITIALIZER; >> >> #define LINE_SZ 1024 >> >> @@ -317,9 +315,7 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) >> >> if (level > av_log_level) >> return; >> -#if HAVE_PTHREADS >> - pthread_mutex_lock(&mutex); >> -#endif >> + ff_mutex_lock(&mutex); >> >> format_line(ptr, level, fmt, vl, part, &print_prefix, type); >> snprintf(line, sizeof(line), "%s%s%s%s", part[0].str, part[1].str, part[2].str, part[3].str); >> @@ -356,9 +352,7 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) >> #endif >> end: >> av_bprint_finalize(part+3, NULL); >> -#if HAVE_PTHREADS >> - pthread_mutex_unlock(&mutex); >> -#endif >> + ff_mutex_unlock(&mutex); >> } >> >> static void (*av_log_callback)(void*, int, const char*, va_list) = > > LGTM Pushed.
diff --git a/libavutil/log.c b/libavutil/log.c index 7a6dd936e5..bd47f2a25f 100644 --- a/libavutil/log.c +++ b/libavutil/log.c @@ -39,11 +39,9 @@ #include "common.h" #include "internal.h" #include "log.h" +#include "thread.h" -#if HAVE_PTHREADS -#include <pthread.h> -static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; -#endif +static AVMutex mutex = AV_MUTEX_INITIALIZER; #define LINE_SZ 1024 @@ -317,9 +315,7 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) if (level > av_log_level) return; -#if HAVE_PTHREADS - pthread_mutex_lock(&mutex); -#endif + ff_mutex_lock(&mutex); format_line(ptr, level, fmt, vl, part, &print_prefix, type); snprintf(line, sizeof(line), "%s%s%s%s", part[0].str, part[1].str, part[2].str, part[3].str); @@ -356,9 +352,7 @@ void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl) #endif end: av_bprint_finalize(part+3, NULL); -#if HAVE_PTHREADS - pthread_mutex_unlock(&mutex); -#endif + ff_mutex_unlock(&mutex); } static void (*av_log_callback)(void*, int, const char*, va_list) =
w32threads and os2threads both support static mutex initialization now, so don't limit it to pthreads only. Signed-off-by: James Almer <jamrial@gmail.com> --- libavutil/log.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)