[threads] Added missing initializers, check errors on mutex/cond calls

This commit is contained in:
Scott Shambarger
2017-01-13 17:32:59 -05:00
parent ca6836f638
commit b54d94fda6
8 changed files with 207 additions and 93 deletions

View File

@@ -44,8 +44,6 @@
# include <sys/event.h>
#endif
#include <pthread.h>
#include <getopt.h>
#include <event2/event.h>
#include <libavutil/log.h>
@@ -422,26 +420,29 @@ signal_kqueue_cb(int fd, short event, void *arg)
static int
ffmpeg_lockmgr(void **mutex, enum AVLockOp op)
ffmpeg_lockmgr(void **pmutex, enum AVLockOp op)
{
switch (op)
{
case AV_LOCK_CREATE:
*mutex = malloc(sizeof(pthread_mutex_t));
if (!*mutex)
*pmutex = malloc(sizeof(pthread_mutex_t));
if (!*pmutex)
return 1;
return !!pthread_mutex_init(*mutex, NULL);
fork_mutex_init(*pmutex);
return 0;
case AV_LOCK_OBTAIN:
return !!pthread_mutex_lock(*mutex);
fork_mutex_lock(*pmutex);
return 0;
case AV_LOCK_RELEASE:
return !!pthread_mutex_unlock(*mutex);
fork_mutex_unlock(*pmutex);
return 0;
case AV_LOCK_DESTROY:
pthread_mutex_destroy(*mutex);
free(*mutex);
fork_mutex_destroy(*pmutex);
free(*pmutex);
*pmutex = NULL;
return 0;
}