[Libav-user] multithreaded problems

Karoly Horvath rhswdev at gmail.com
Thu Nov 10 14:23:36 CET 2011


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 <h.leppkes at gmail.com>wrote:

> Hi,
>
> On Thu, Nov 10, 2011 at 2:07 AM, Karthik Kailash
> <karthik at freestreammedia.com> 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
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://ffmpeg.org/pipermail/libav-user/attachments/20111110/4d3a5ec9/attachment.html>


More information about the Libav-user mailing list