[vlc-devel] [PATCH] vmem: fixed picture pool use

Sergey Radionov rsatom at gmail.com
Sun Feb 7 11:14:58 CET 2016


---
 modules/video_output/vmem.c | 35 ++++++++++++++++++++++-------------
 1 file changed, 22 insertions(+), 13 deletions(-)

diff --git a/modules/video_output/vmem.c b/modules/video_output/vmem.c
index 5a3c63f..a05a585 100644
--- a/modules/video_output/vmem.c
+++ b/modules/video_output/vmem.c
@@ -109,32 +109,37 @@ 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 void Lock(void *data, picture_t *pic)
+static int Lock(picture_t *pic)
 {
-    vout_display_sys_t *sys = data;
     picture_sys_t *picsys = pic->p_sys;
+    vout_display_sys_t *sys = picsys->sys;
     void *planes[PICTURE_PLANE_MAX];
+    memset(planes, 0, sizeof(planes));
 
     picsys->id = sys->lock(sys->opaque, planes);
 
+    for (int i = 0; i < pic->i_planes; ++i) {
+        if (!planes[i])
+            return VLC_EGENERIC;
+    }
+
     for (int i = 0; i < pic->i_planes; i++)
         pic->p[i].p_pixels = planes[i];
+
+    return VLC_SUCCESS;
 }
 
-static void Unlock(void *data, picture_t *pic)
+static void Unlock(picture_t *pic)
 {
-    vout_display_sys_t *sys = data;
     picture_sys_t *picsys = pic->p_sys;
+    vout_display_sys_t *sys = picsys->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);
-
 }
 
 /*****************************************************************************
@@ -269,7 +274,6 @@ static void Close(vlc_object_t *object)
 
     if (sys->pool)
     {
-        picture_pool_Enum(sys->pool, Unlock, sys);
         picture_pool_Release(sys->pool);
     }
     free(sys);
@@ -315,23 +319,29 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
     }
 
     /* */
-    sys->pool = picture_pool_New(count, pictures);
+    picture_pool_configuration_t cfg = {
+        .picture_count = count,
+        .picture = pictures,
+        .lock = Lock,
+        .unlock = Unlock
+    };
+
+    sys->pool = picture_pool_NewExtended(&cfg);
     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 Prepare(vout_display_t *vd, picture_t *pic, subpicture_t *subpic)
 {
-    Unlock(vd->sys, pic);
+    VLC_UNUSED(vd);
+    VLC_UNUSED(pic);
     VLC_UNUSED(subpic);
 }
 
-
 static void Display(vout_display_t *vd, picture_t *pic, subpicture_t *subpic)
 {
     vout_display_sys_t *sys = vd->sys;
@@ -339,7 +349,6 @@ static void Display(vout_display_t *vd, picture_t *pic, subpicture_t *subpic)
     if (sys->display != NULL)
         sys->display(sys->opaque, pic->p_sys->id);
 
-    Lock(sys, pic);
     picture_Release(pic);
     VLC_UNUSED(subpic);
 }
-- 
2.6.3.windows.1



More information about the vlc-devel mailing list