[vlc-commits] vout: kms: don't use a custom picture destroy

Steve Lhomme git at videolan.org
Mon Aug 10 08:51:47 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Tue Jul 21 12:59:01 2020 +0200| [4412866bfe5f4d85d637b8e04f9738589c5571de] | committer: Steve Lhomme

vout: kms: don't use a custom picture destroy

The picture is not used outside of this file. We don't need to use the picture
release refcount to release the resources used in the picture.

That's how other display modules handle their dummy local picture. The picture
is allocated locally and the resources are released locally at the end.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=4412866bfe5f4d85d637b8e04f9738589c5571de
---

 modules/video_output/kms.c | 25 +++----------------------
 1 file changed, 3 insertions(+), 22 deletions(-)

diff --git a/modules/video_output/kms.c b/modules/video_output/kms.c
index be4a666978..acbd7ef5d5 100644
--- a/modules/video_output/kms.c
+++ b/modules/video_output/kms.c
@@ -101,11 +101,6 @@ struct vout_display_sys_t {
     int             drm_fd;
 };
 
-typedef struct {
-    vout_display_sys_t  *p_voutsys;
-} picture_sys_t;
-
-
 static void DestroyFB(vout_display_sys_t const *sys, uint32_t const buf)
 {
     struct drm_mode_destroy_dumb destroy_req = { .handle = sys->handle[buf] };
@@ -491,10 +486,8 @@ static bool ChromaNegotiation(vout_display_t *vd)
     return false;
 }
 
-static void CustomDestroyPicture(picture_t *p_picture)
+static void CustomDestroyPicture(vout_display_sys_t *sys)
 {
-    picture_sys_t *psys = (picture_sys_t*)p_picture->p_sys;
-    vout_display_sys_t *sys = (vout_display_sys_t *)psys->p_voutsys;
     int c;
 
     for (c = 0; c < MAXHWBUF; c++)
@@ -504,7 +497,6 @@ static void CustomDestroyPicture(picture_t *p_picture)
     drmDropMaster(sys->drm_fd);
     vlc_close(sys->drm_fd);
     sys->drm_fd = 0;
-    free(p_picture->p_sys);
 }
 
 static int OpenDisplay(vout_display_t *vd)
@@ -584,14 +576,7 @@ static int OpenDisplay(vout_display_t *vd)
     if (!found_connector)
         goto err_out;
 
-    picture_sys_t *psys = calloc(1, sizeof(*psys));
-    if (psys == NULL)
-        goto err_out;
-
-    picture_resource_t rsc = {
-        .p_sys = psys,
-        .pf_destroy = CustomDestroyPicture,
-    };
+    picture_resource_t rsc = { 0 };
 
     for (size_t i = 0; i < PICTURE_PLANE_MAX; i++) {
         rsc.p[i].p_pixels = sys->map[0] + sys->offsets[i];
@@ -599,15 +584,10 @@ static int OpenDisplay(vout_display_t *vd)
         rsc.p[i].i_pitch  = sys->stride;
     }
 
-    psys->p_voutsys = sys;
-
     sys->picture = picture_NewFromResource(&vd->fmt, &rsc);
 
     if (!sys->picture)
-    {
-        free(psys);
         goto err_out;
-    }
 
     return VLC_SUCCESS;
 err_out:
@@ -676,6 +656,7 @@ static void Close(vout_display_t *vd)
 
     if (sys->picture)
         picture_Release(sys->picture);
+    CustomDestroyPicture(sys);
 
     if (sys->drm_fd)
         drmDropMaster(sys->drm_fd);



More information about the vlc-commits mailing list