From 63cbb090702a73b5cce656f990152fc9fb2a5e57 Mon Sep 17 00:00:00 2001 From: Brian Matherly Date: Wed, 18 Jan 2012 21:45:07 -0600 Subject: [PATCH] Add use of av_lockmgr_register in addition to the existing mutex for avformat services. --- src/modules/avformat/factory.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/modules/avformat/factory.c b/src/modules/avformat/factory.c index e7fbb6c0..800261b8 100644 --- a/src/modules/avformat/factory.c +++ b/src/modules/avformat/factory.c @@ -69,6 +69,31 @@ void av_free( void *ptr ) } #endif +static int avformat_lockmgr(void **mutex, enum AVLockOp op) +{ + pthread_mutex_t** pmutex = (pthread_mutex_t**) mutex; + + switch (op) + { + case AV_LOCK_CREATE: + *pmutex = (pthread_mutex_t*) malloc(sizeof(pthread_mutex_t)); + pthread_mutex_init(*pmutex, NULL); + break; + case AV_LOCK_OBTAIN: + pthread_mutex_lock(*pmutex); + break; + case AV_LOCK_RELEASE: + pthread_mutex_unlock(*pmutex); + break; + case AV_LOCK_DESTROY: + pthread_mutex_destroy(*pmutex); + free(*pmutex); + break; + } + + return 0; +} + void avformat_destroy( void *ignore ) { // Clean up @@ -97,6 +122,7 @@ static void avformat_init( ) { avformat_initialised = 1; pthread_mutex_init( &avformat_mutex, NULL ); + av_lockmgr_register( &avformat_lockmgr ); av_register_all( ); #ifdef AVDEVICE avdevice_register_all(); -- 2.39.2