Skip to content

Commit

Permalink
vmem: unlock picture in prepare, get rid of lock/unlock
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémi Denis-Courmont committed Nov 3, 2014
1 parent d7d0b38 commit 5dfce5e
Showing 1 changed file with 46 additions and 47 deletions.
93 changes: 46 additions & 47 deletions modules/video_output/vmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,37 @@ typedef unsigned (*vlc_format_cb)(void **, char *, unsigned *, unsigned *,
unsigned *, unsigned *);

static picture_pool_t *Pool (vout_display_t *, unsigned);
static void Prepare(vout_display_t *, picture_t *, subpicture_t *);
static void Display(vout_display_t *, picture_t *, subpicture_t *);
static int Control(vout_display_t *, int, va_list);

static int Lock(picture_t *);
static void Unlock(picture_t *);
static void Lock(void *data, picture_t *pic)
{
vout_display_sys_t *sys = data;
picture_sys_t *picsys = pic->p_sys;
void *planes[PICTURE_PLANE_MAX];

picsys->id = sys->lock(sys->opaque, planes);

for (int i = 0; i < pic->i_planes; i++)
pic->p[i].p_pixels = planes[i];
}

static void Unlock(void *data, picture_t *pic)
{
vout_display_sys_t *sys = data;
picture_sys_t *picsys = pic->p_sys;
void *planes[PICTURE_PLANE_MAX];

assert(!picture_IsReferenced(pic));

for (int i = 0; i < pic->i_planes; i++)
planes[i] = pic->p[i].p_pixels;

if (sys->unlock != NULL)
sys->unlock(sys->opaque, picsys->id, planes);

}

/*****************************************************************************
* Open: allocates video thread
Expand Down Expand Up @@ -221,7 +247,7 @@ static int Open(vlc_object_t *object)
vd->fmt = fmt;
vd->info = info;
vd->pool = Pool;
vd->prepare = NULL;
vd->prepare = Prepare;
vd->display = Display;
vd->control = Control;
vd->manage = NULL;
Expand All @@ -240,11 +266,12 @@ static void Close(vlc_object_t *object)

if (sys->cleanup)
sys->cleanup(sys->opaque);

picture_pool_Enum(sys->pool, Unlock, sys);
picture_pool_Release(sys->pool);
free(sys);
}

/* */
static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
{
vout_display_sys_t *sys = vd->sys;
Expand Down Expand Up @@ -285,65 +312,37 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
}

/* */
picture_pool_configuration_t pool;
memset(&pool, 0, sizeof(pool));
pool.picture_count = count;
pool.picture = pictures;
pool.lock = Lock;
pool.unlock = Unlock;
sys->pool = picture_pool_NewExtended(&pool);
sys->pool = picture_pool_New(count, pictures);
if (!sys->pool) {
for (unsigned i = 0; i < count; i++)
picture_Release(pictures[i]);
}

picture_pool_Enum(sys->pool, Lock, sys);
return sys->pool;
}

static void Display(vout_display_t *vd, picture_t *picture, subpicture_t *subpicture)
static void Prepare(vout_display_t *vd, picture_t *pic, subpicture_t *subpic)
{
vout_display_sys_t *sys = vd->sys;
void *id = picture->p_sys->id;

assert(!picture_IsReferenced(picture));
picture_Release(picture);

if (sys->display != NULL)
sys->display(sys->opaque, id);
VLC_UNUSED(subpicture);
Unlock(vd->sys, pic);
VLC_UNUSED(subpic);
}

static int Control(vout_display_t *vd, int query, va_list args)
{
(void) vd; (void) query; (void) args;
return VLC_EGENERIC;
}

/* */
static int Lock(picture_t *picture)
static void Display(vout_display_t *vd, picture_t *pic, subpicture_t *subpic)
{
picture_sys_t *picsys = picture->p_sys;
vout_display_sys_t *sys = picsys->sys;
void *planes[PICTURE_PLANE_MAX];

picsys->id = sys->lock(sys->opaque, planes);
vout_display_sys_t *sys = vd->sys;

for (int i = 0; i < picture->i_planes; i++)
picture->p[i].p_pixels = planes[i];
if (sys->display != NULL)
sys->display(sys->opaque, pic->p_sys->id);

return VLC_SUCCESS;
Lock(sys, pic);
picture_Release(pic);
VLC_UNUSED(subpic);
}

static void Unlock(picture_t *picture)
static int Control(vout_display_t *vd, int query, va_list args)
{
picture_sys_t *picsys = picture->p_sys;
vout_display_sys_t *sys = picsys->sys;

void *planes[PICTURE_PLANE_MAX];

for (int i = 0; i < picture->i_planes; i++)
planes[i] = picture->p[i].p_pixels;

if (sys->unlock != NULL)
sys->unlock(sys->opaque, picsys->id, planes);
(void) vd; (void) query; (void) args;
return VLC_EGENERIC;
}

0 comments on commit 5dfce5e

Please sign in to comment.