Go to the documentation of this file.
22 #ifndef AVUTIL_THREAD_H
23 #define AVUTIL_THREAD_H
27 #if HAVE_PTHREADS || HAVE_W32THREADS || HAVE_OS2THREADS
32 #if defined(ASSERT_LEVEL) && ASSERT_LEVEL > 1
40 #define ASSERT_PTHREAD_ABORT(func, ret) do { \
41 char errbuf[AV_ERROR_MAX_STRING_SIZE] = ""; \
42 av_log(NULL, AV_LOG_FATAL, AV_STRINGIFY(func) \
43 " failed with error: %s\n", \
44 av_make_error_string(errbuf, AV_ERROR_MAX_STRING_SIZE, \
49 #define ASSERT_PTHREAD_NORET(func, ...) do { \
50 int ret = func(__VA_ARGS__); \
52 ASSERT_PTHREAD_ABORT(func, ret); \
55 #define ASSERT_PTHREAD(func, ...) do { \
56 ASSERT_PTHREAD_NORET(func, __VA_ARGS__); \
60 static inline int strict_pthread_join(
pthread_t thread,
void **value_ptr)
71 ASSERT_PTHREAD_NORET(pthread_mutexattr_init, &local_attr);
72 ASSERT_PTHREAD_NORET(pthread_mutexattr_settype, &local_attr, PTHREAD_MUTEX_ERRORCHECK);
74 ASSERT_PTHREAD_NORET(pthread_mutexattr_destroy, &local_attr);
120 const struct timespec *abstime)
123 if (
ret &&
ret != ETIMEDOUT)
128 static inline int strict_pthread_once(
pthread_once_t *once_control,
void (*init_routine)(
void))
130 ASSERT_PTHREAD(
pthread_once, once_control, init_routine);
133 #define pthread_join strict_pthread_join
134 #define pthread_mutex_init strict_pthread_mutex_init
135 #define pthread_mutex_destroy strict_pthread_mutex_destroy
136 #define pthread_mutex_lock strict_pthread_mutex_lock
137 #define pthread_mutex_unlock strict_pthread_mutex_unlock
138 #define pthread_cond_init strict_pthread_cond_init
139 #define pthread_cond_destroy strict_pthread_cond_destroy
140 #define pthread_cond_signal strict_pthread_cond_signal
141 #define pthread_cond_broadcast strict_pthread_cond_broadcast
142 #define pthread_cond_wait strict_pthread_cond_wait
143 #define pthread_cond_timedwait strict_pthread_cond_timedwait
144 #define pthread_once strict_pthread_once
147 #elif HAVE_OS2THREADS
153 #define AVMutex pthread_mutex_t
154 #define AV_MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER
156 #define ff_mutex_init pthread_mutex_init
157 #define ff_mutex_lock pthread_mutex_lock
158 #define ff_mutex_unlock pthread_mutex_unlock
159 #define ff_mutex_destroy pthread_mutex_destroy
161 #define AVOnce pthread_once_t
162 #define AV_ONCE_INIT PTHREAD_ONCE_INIT
164 #define ff_thread_once(control, routine) pthread_once(control, routine)
169 #define AV_MUTEX_INITIALIZER 0
177 #define AV_ONCE_INIT 0
static av_always_inline int pthread_join(pthread_t thread, void **value_ptr)
static int ff_mutex_init(AVMutex *mutex, const void *attr)
static av_always_inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
static int ff_mutex_unlock(AVMutex *mutex)
static int ff_thread_once(char *control, void(*routine)(void))
static av_always_inline int pthread_cond_broadcast(pthread_cond_t *cond)
static av_always_inline int pthread_once(pthread_once_t *once_control, void(*init_routine)(void))
#define pthread_mutex_unlock(a)
static int ff_mutex_destroy(AVMutex *mutex)
static int ff_mutex_lock(AVMutex *mutex)
static av_always_inline int pthread_cond_destroy(pthread_cond_t *cond)
static av_always_inline int pthread_mutex_destroy(pthread_mutex_t *mutex)
static av_always_inline int pthread_cond_signal(pthread_cond_t *cond)
static av_always_inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
static av_always_inline int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime)
static av_always_inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
int(* cond)(enum AVPixelFormat pix_fmt)
#define pthread_mutex_lock(a)