diff options
author | Hendrik Leppkes <h.leppkes@gmail.com> | 2014-05-08 17:16:55 +0400 |
---|---|---|
committer | Hendrik Leppkes <h.leppkes@gmail.com> | 2014-05-08 17:18:32 +0400 |
commit | 41fefb51b93c9e7282307998f2d095cce514d149 (patch) | |
tree | f5239ad2b1e18fa897cad0a9fe463665b1ebf49a | |
parent | f5119d37c679c82d75f59824f4109f9db847975e (diff) |
pthread_lockmgr: use a recursive pthreads mutexmpc-hc-1.7.5-2
This allows locking the same mutex multiple times from the same thread,
which can happen easily in some situations.
-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 b899392fcc..0cc8c16498 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); } |