[vlc-devel] [PATCH 1/2] kms: setup the picture from the frame buffer early

Steve Lhomme robux4 at ycbcr.xyz
Tue Feb 26 09:24:29 CET 2019


---
 modules/video_output/kms.c | 55 +++++++++++++++++++-------------------
 1 file changed, 27 insertions(+), 28 deletions(-)

diff --git a/modules/video_output/kms.c b/modules/video_output/kms.c
index 3417d07a9d..6a5e9dbb19 100644
--- a/modules/video_output/kms.c
+++ b/modules/video_output/kms.c
@@ -573,6 +573,30 @@ static int OpenDisplay(vout_display_t *vd)
     if (!found_connector)
         goto err_out;
 
+    picture_resource_t rsc;
+    memset(&rsc, 0, sizeof(rsc));
+
+    for (i = 0; i < PICTURE_PLANE_MAX; i++) {
+        rsc.p[i].p_pixels = sys->map[0] + sys->offsets[i];
+        rsc.p[i].i_lines  = sys->height;
+        rsc.p[i].i_pitch  = sys->stride;
+    }
+
+    picture_sys_t *psys = calloc(1, sizeof(*psys));
+    if (psys == NULL)
+        goto err_out;
+
+    psys->p_voutsys = sys;
+    rsc.p_sys = psys;
+    rsc.pf_destroy = CustomDestroyPicture;
+
+    sys->picture = picture_NewFromResource(&vd->fmt, &rsc);
+    if (unlikely(sys->picture == NULL))
+    {
+        free(p_sys);
+        goto err_out;
+    }
+
     return VLC_SUCCESS;
 err_out:
     drmDropMaster(sys->drm_fd);
@@ -613,37 +637,10 @@ static picture_pool_t *Pool(vout_display_t *vd, unsigned count)
     VLC_UNUSED(count);
     vout_display_sys_t *sys = vd->sys;
     picture_sys_t *psys;
-    picture_resource_t rsc;
     int i;
 
-    if (!sys->pool && !sys->picture) {
-        memset(&rsc, 0, sizeof(rsc));
-
-        for (i = 0; i < PICTURE_PLANE_MAX; i++) {
-            rsc.p[i].p_pixels = sys->map[0]+sys->offsets[i];
-            rsc.p[i].i_lines  = sys->height;
-            rsc.p[i].i_pitch  = sys->stride;
-        }
-
-        psys = calloc(1, sizeof(*psys));
-        if (psys == NULL)
-            return NULL;
-
-        psys->p_voutsys = sys;
-        rsc.p_sys = psys;
-        rsc.pf_destroy = CustomDestroyPicture;
-
-        sys->picture = picture_NewFromResource(&vd->fmt, &rsc);
-
-        if (!sys->picture) {
-            free((void*)psys);
-            return NULL;
-        }
-
+    if (!sys->pool)
         sys->pool = picture_pool_New(1, &sys->picture);
-        if (!sys->pool)
-            picture_Release(sys->picture);
-    }
 
     return sys->pool;
 }
@@ -682,6 +679,8 @@ static void Close(vout_display_t *vd)
 
     if (sys->pool)
         picture_pool_Release(sys->pool);
+    else
+        picture_Release(sys->picture);
 
     if (sys->drm_fd)
         drmDropMaster(sys->drm_fd);
-- 
2.17.1



More information about the vlc-devel mailing list