Apparantly, FFmpeg has lock management now, and from the tracing, it is indeed

used. Spotted this on the libav*-user mailing list.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@33346 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2009-09-29 09:04:05 +00:00
parent ea40a61a84
commit 885513f0a0
@@ -16,6 +16,8 @@
#include <new>
#include <Locker.h>
extern "C" {
#include "avformat.h"
}
@@ -29,8 +31,59 @@ extern "C" {
#include "MuxerTable.h"
//#define TRACE_FFMPEG_PLUGIN
#ifdef TRACE_FFMPEG_PLUGIN
# define TRACE printf
#else
# define TRACE(a...)
#endif
#define ERROR(a...) fprintf(stderr, a)
static int
manage_locks(void** _lock, enum AVLockOp operation)
{
TRACE("manage_locks(%p, %d)\n", *_lock, operation);
BLocker** lock = reinterpret_cast<BLocker**>(_lock);
switch (operation) {
case AV_LOCK_CREATE:
TRACE(" AV_LOCK_CREATE\n");
*lock = new(std::nothrow) BLocker("FFmpeg lock");
if (*lock == NULL)
return 1;
break;
case AV_LOCK_OBTAIN:
TRACE(" AV_LOCK_OBTAIN\n");
if (!(*lock)->Lock())
return 1;
break;
case AV_LOCK_RELEASE:
TRACE(" AV_LOCK_RELEASE\n");
(*lock)->Unlock();
break;
case AV_LOCK_DESTROY:
TRACE(" AV_LOCK_DESTROY\n");
delete *lock;
break;
default:
return 1;
}
return 0;
}
FFmpegPlugin::GlobalInitilizer::GlobalInitilizer()
{
if (av_lockmgr_register(manage_locks) != 0)
ERROR("Failed to register lock management!\n");
av_register_all();
// This will also call av_codec_init() by registering codecs.
}
@@ -38,7 +91,7 @@ FFmpegPlugin::GlobalInitilizer::GlobalInitilizer()
FFmpegPlugin::GlobalInitilizer::~GlobalInitilizer()
{
// TODO: uninit anything here?
av_lockmgr_register(NULL);
}