diff options
author | Martin Storsjö <martin@martin.st> | 2011-10-30 01:20:15 +0300 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2011-11-05 12:08:53 +0200 |
commit | 2d1b6fb72bd3d37798d448ba32ba85ee0eabd9e3 (patch) | |
tree | fea1310ec13caea957bd5ed593ce6b05e0835a36 /libavcodec/utils.c | |
parent | f6d371009678e46877e6f81ab0eae475d41b1f57 (diff) | |
download | ffmpeg-2d1b6fb72bd3d37798d448ba32ba85ee0eabd9e3.tar.gz |
avcodec: Allow locking and unlocking an avformat specific mutex
This extends the lock manager in avcodec to manage two separate
mutexes via the user-specified lock functions.
Signed-off-by: Martin Storsjö <martin@martin.st>
Diffstat (limited to 'libavcodec/utils.c')
-rw-r--r-- | libavcodec/utils.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/libavcodec/utils.c b/libavcodec/utils.c index 35c9eebc3a..cd8dce91fc 100644 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@ -48,6 +48,7 @@ static int volatile entangled_thread_counter=0; static int (*ff_lockmgr_cb)(void **mutex, enum AVLockOp op); static void *codec_mutex; +static void *avformat_mutex; void *av_fast_realloc(void *ptr, unsigned int *size, size_t min_size) { @@ -1270,6 +1271,8 @@ int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)) if (ff_lockmgr_cb) { if (ff_lockmgr_cb(&codec_mutex, AV_LOCK_DESTROY)) return -1; + if (ff_lockmgr_cb(&avformat_mutex, AV_LOCK_DESTROY)) + return -1; } ff_lockmgr_cb = cb; @@ -1277,6 +1280,26 @@ int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op)) if (ff_lockmgr_cb) { if (ff_lockmgr_cb(&codec_mutex, AV_LOCK_CREATE)) return -1; + if (ff_lockmgr_cb(&avformat_mutex, AV_LOCK_CREATE)) + return -1; + } + return 0; +} + +int avpriv_lock_avformat(void) +{ + if (ff_lockmgr_cb) { + if ((*ff_lockmgr_cb)(&avformat_mutex, AV_LOCK_OBTAIN)) + return -1; + } + return 0; +} + +int avpriv_unlock_avformat(void) +{ + if (ff_lockmgr_cb) { + if ((*ff_lockmgr_cb)(&avformat_mutex, AV_LOCK_RELEASE)) + return -1; } return 0; } |