[vlc-commits] XCB/X11: keep SysV segment pointer only

Rémi Denis-Courmont git at videolan.org
Sun Jul 14 17:47:02 CEST 2013


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Jul 14 18:33:17 2013 +0300| [2a8fb6196ee87d216c9f257f9f405a3f09f4d47f] | committer: Rémi Denis-Courmont

XCB/X11: keep SysV segment pointer only

...rather than the whole picture resource structure.

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

 modules/video_output/xcb/x11.c |   43 +++++++++++++++++++++-------------------
 1 file changed, 23 insertions(+), 20 deletions(-)

diff --git a/modules/video_output/xcb/x11.c b/modules/video_output/xcb/x11.c
index 54bfb51..9d802aa 100644
--- a/modules/video_output/xcb/x11.c
+++ b/modules/video_output/xcb/x11.c
@@ -74,7 +74,7 @@ struct vout_display_sys_t
     uint8_t depth; /* useful bits per pixel */
 
     picture_pool_t *pool; /* picture pool */
-    picture_resource_t resource[MAX_PICTURES];
+    void *segments[MAX_PICTURES];
 };
 
 static picture_pool_t *Pool (vout_display_t *, unsigned);
@@ -379,29 +379,36 @@ static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count)
         return NULL;
 
     assert (pic->i_planes == 1);
-    memset (sys->resource, 0, sizeof(sys->resource));
 
     unsigned count;
     picture_t *pic_array[MAX_PICTURES];
+
+    for (count = 0; count < MAX_PICTURES; count++)
+        sys->segments[count] = NULL;
     for (count = 0; count < MAX_PICTURES; count++)
     {
-        picture_resource_t *res = &sys->resource[count];
+        picture_resource_t res = {
+           .p = {
+               [0] = {
+                   .i_lines = pic->p->i_lines,
+                   .i_pitch = pic->p->i_pitch,
+               },
+           },
+        };
+        xcb_shm_seg_t seg = (sys->seg_base != 0) ? (sys->seg_base + count) : 0;
 
-        res->p->i_lines = pic->p->i_lines;
-        res->p->i_pitch = pic->p->i_pitch;
-        if (XCB_pictures_Alloc (vd, res, res->p->i_pitch * res->p->i_lines,
-                                sys->conn,
-                                sys->seg_base ? (sys->seg_base + count) : 0))
+        if (XCB_pictures_Alloc (vd, &res, res.p->i_pitch * res.p->i_lines,
+                                sys->conn, seg))
             break;
-        pic_array[count] = picture_NewFromResource (&vd->fmt, res);
+        pic_array[count] = picture_NewFromResource (&vd->fmt, &res);
         if (!pic_array[count])
         {
-            XCB_pictures_Free (res->p->p_pixels);
-            if (res->p_sys->segment)
-                xcb_shm_detach (sys->conn, res->p_sys->segment);
-            memset (res, 0, sizeof(*res));
+            XCB_pictures_Free (res.p[0].p_pixels);
+            if (seg != 0)
+                xcb_shm_detach (sys->conn, seg);
             break;
         }
+        sys->segments[count] = res.p[0].p_pixels;
     }
     picture_Release (pic);
 
@@ -574,13 +581,9 @@ static void ResetPictures (vout_display_t *vd)
 
     for (unsigned i = 0; i < MAX_PICTURES; i++)
     {
-        picture_resource_t *res = &sys->resource[i];
-
-        if (!res->p->p_pixels)
-            break;
-        XCB_pictures_Free (res->p->p_pixels);
-        if (res->p_sys->segment)
-            xcb_shm_detach (sys->conn, res->p_sys->segment);
+        XCB_pictures_Free (sys->segments[i]);
+        if (sys->seg_base != 0)
+            xcb_shm_detach (sys->conn, sys->seg_base + i);
     }
     picture_pool_Delete (sys->pool);
     sys->pool = NULL;



More information about the vlc-commits mailing list