Hello All:
Just did a test on making the ffmpeg thread safe. You should not have
to modify the plugin but here is a cut and past:
extern "C"
{
int ffmpeg_lock_callback(void **mutex, enum AVLockOp op);
}
int ffmpeg_lock_callback(void **mutex, enum AVLockOp op)
{
static OpenThreads::Mutex m;
switch(op)
{
case AV_LOCK_CREATE:
{
*mutex = &m;
break;
}
case AV_LOCK_OBTAIN:
{
((OpenThreads::Mutex*)(*mutex))->lock();
break;
}
case AV_LOCK_RELEASE:
{
((OpenThreads::Mutex*)(*mutex))->unlock();
break;
}
case AV_LOCK_DESTROY:
{
*mutex = 0;
break;
}
}
return 0;
}
You can then register your function via the avcodec interface call:
av_lockmgr_register(&ffmpeg_lock_callback);
To me this needs to be done at the application level. doing this will
automatically allow for thread safe access to parts of libavcodec that
need it. ffmpeg calls the callback method and passes the different
ops it would like you to do.
you probably could have gotten rid of the type casts and just access
the Mutex lock directly.
Take care
Garrett
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org