[FFmpeg-devel] [PATCH] avcodec thread safety fix
Andreas Öman
andreas
Sun May 31 09:07:33 CEST 2009
Baptiste Coudurier wrote:
> Hi,
>
> Andreas ?man wrote:
>> Art Clarke wrote:
>>> So I take back my recommendation :) Ship it.
>> Ok, I've applied the patch now. And i've also tested it with my
>> own mediaplayer and it seems to work fine.
>>
>
> Your own ? What is it ? :)
http://www.lonelycoder.com/hts
It uses FFmpeg not only for playing media, but also for loading
all images/icons, etc in the UI using lots of threads so it's
quite thread intensive.
> Btw, it may be nice to have an example of its utilization, it would help
> users for sure.
Sure, a typical callback would look like this (for pthreads).
Perhaps add this to APIChanges?
static int
lockmgr(void **mtx, enum AVLockOp op)
{
switch(op) {
case AV_LOCK_CREATE:
*mtx = malloc(sizeof(pthread_mutex_t));
if(!*mtx)
return 1;
return !!pthread_mutex_init(*mtx, NULL);
case AV_LOCK_OBTAIN:
return !!pthread_mutex_lock(*mtx);
case AV_LOCK_RELEASE:
return !!pthread_mutex_unlock(*mtx);
case AV_LOCK_DESTROY:
pthread_mutex_destroy(*mtx);
free(*mtx);
return 0;
}
return 1;
}
// During application startup.
if(av_lockmgr_register(lockmgr)) {
// Failure
}
// During application shutdown.
av_lockmgr_register(NULL);
More information about the ffmpeg-devel
mailing list