Thank you for all of your responses, it works like a charm! :)

static int ff_lockmgr(void **mutex, enum AVLockOp op)
{
   pthread_mutex_t** pmutex = (pthread_mutex_t**) mutex;
   switch (op) {
   case AV_LOCK_CREATE:
      *pmutex = (pthread_mutex_t*) malloc(sizeof(pthread_mutex_t));
       pthread_mutex_init(*pmutex, NULL);
       break;
   case AV_LOCK_OBTAIN:
       pthread_mutex_lock(*pmutex);
       break;
   case AV_LOCK_RELEASE:
       pthread_mutex_unlock(*pmutex);
       break;
   case AV_LOCK_DESTROY:
       pthread_mutex_destroy(*pmutex);
       free(*pmutex);
       break;
   }
   return 0;
}

-- 
Karoly Horvath
http://softwaredevel.wikispaces.com/


On Thu, Nov 10, 2011 at 10:13 AM, Hendrik Leppkes <[email protected]>wrote:

> Hi,
>
> On Thu, Nov 10, 2011 at 2:07 AM, Karthik Kailash
> <[email protected]> wrote:
> > Is there an example of how to use av_lockmgr_register()?  I am not 100%
> > clear upon reading the documentation of what the callback function that I
> > pass in is supposed to do.
>
> This is my implementation of the lockmgr using the Windows Critical
> Sections. It may not apply to you, but it does give you an idea what
> to do.
> Error checking was left out for brevity.
>
> static int ff_lockmgr(void **mutex, enum AVLockOp op)
> {
>        CRITICAL_SECTION **critSec = (CRITICAL_SECTION **)mutex;
>        switch (op) {
>        case AV_LOCK_CREATE:
>                *critSec = new CRITICAL_SECTION();
>                InitializeCriticalSection(*critSec);
>                break;
>        case AV_LOCK_OBTAIN:
>                EnterCriticalSection(*critSec);
>                break;
>        case AV_LOCK_RELEASE:
>                LeaveCriticalSection(*critSec);
>                break;
>        case AV_LOCK_DESTROY:
>                DeleteCriticalSection(*critSec);
>                delete *critSec;
>                break;
>        }
>        return 0;
> }
> _______________________________________________
> Libav-user mailing list
> [email protected]
> http://ffmpeg.org/mailman/listinfo/libav-user
>
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to