[Libav-user] multithreaded problems

Hendrik Leppkes h.leppkes at gmail.com
Thu Nov 10 11:13:24 CET 2011


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;
}


More information about the Libav-user mailing list