[vlc-commits] vmem: unlock picture in prepare, get rid of lock/unlock
Rémi Denis-Courmont
git at videolan.org
Mon Nov 3 21:40:45 CET 2014
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Nov 3 22:39:34 2014 +0200| [5dfce5edb5db6ad71e0fd9b797ff8205ec45c7e4] | committer: Rémi Denis-Courmont
vmem: unlock picture in prepare, get rid of lock/unlock
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5dfce5edb5db6ad71e0fd9b797ff8205ec45c7e4
---
modules/video_output/vmem.c | 93 +++++++++++++++++++++----------------------
1 file changed, 46 insertions(+), 47 deletions(-)
diff --git a/modules/video_output/vmem.c b/modules/video_output/vmem.c
index 97055cb..3f117da 100644
--- a/modules/video_output/vmem.c
+++ b/modules/video_output/vmem.c
@@ -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
@@ -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;
@@ -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;
@@ -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;
}
More information about the vlc-commits
mailing list