diff options
author | Hendrik Leppkes <h.leppkes@gmail.com> | 2014-05-08 17:16:55 +0400 |
---|---|---|
committer | Hendrik Leppkes <h.leppkes@gmail.com> | 2017-08-04 20:12:12 +0300 |
commit | 2dd2a8322d41415c5b39eda06dc6ecb3534c82a9 (patch) | |
tree | fd9bf3db1cb4ff5e0914f2df376f9fa333c2bd97 /libavcodec | |
parent | cd05141bf4d6fb03aa6e870576e5210b9f3a490c (diff) |
pthread_lockmgr: use a recursive pthreads mutex
This allows locking the same mutex multiple times from the same thread,
which can happen easily in some situations.
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/utils.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 1336e921c9..368c6c2222 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -79,7 +79,16 @@ static int default_lockmgr_cb(void **arg, enum AVLockOp op) pthread_mutex_t *tmp = av_malloc(sizeof(pthread_mutex_t)); if (!tmp) return AVERROR(ENOMEM); - if ((err = pthread_mutex_init(tmp, NULL))) { +#if HAVE_PTHREADS + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + err = pthread_mutex_init(tmp, &attr); + pthread_mutexattr_destroy(&attr); +#else + err = pthread_mutex_init(tmp, NULL); +#endif + if (err) { av_free(tmp); return AVERROR(err); } |