Hello ALl:
Forgot one thing. You must add --enable-pthreads (for unix type
builds and MACs) for your platform. I forget the windows one but do
the --help and look at the thread enabler for your platform.
Take care
Garrett
On Jan 11, 2010, at 12:44 PM, Garrett Potts wrote:
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
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org