From: Brian Matherly Date: Thu, 19 Jan 2012 03:45:07 +0000 (-0600) Subject: Add use of av_lockmgr_register in addition to the existing mutex for X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=63cbb090702a73b5cce656f990152fc9fb2a5e57;p=mlt Add use of av_lockmgr_register in addition to the existing mutex for avformat services. --- 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();