[vlc-commits] XCB: factor segment detachment on error

Rémi Denis-Courmont git at videolan.org
Sat Oct 4 11:19:37 CEST 2014


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Oct  4 11:53:17 2014 +0300| [89c0c777d2391cfbcf05ce45b548b61978174919] | committer: Rémi Denis-Courmont

XCB: factor segment detachment on error

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

 modules/video_output/xcb/pictures.c |    9 ++++++++-
 modules/video_output/xcb/pictures.h |    3 ++-
 modules/video_output/xcb/x11.c      |    7 ++-----
 modules/video_output/xcb/xvideo.c   |    3 ++-
 4 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/modules/video_output/xcb/pictures.c b/modules/video_output/xcb/pictures.c
index b2c1fce..ed449bf 100644
--- a/modules/video_output/xcb/pictures.c
+++ b/modules/video_output/xcb/pictures.c
@@ -150,10 +150,17 @@ int XCB_picture_Alloc (vout_display_t *vd, picture_resource_t *res,
 }
 
 picture_t *XCB_picture_NewFromResource (const video_format_t *restrict fmt,
-                                        const picture_resource_t *restrict res)
+                                        const picture_resource_t *restrict res,
+                                        xcb_connection_t *conn)
 {
     picture_t *pic = picture_NewFromResource (fmt, res);
     if (unlikely(pic == NULL))
+    {
+        xcb_shm_seg_t seg = (uintptr_t)res->p_sys;
+
+        if (seg != 0)
+            xcb_shm_detach (conn, seg);
         shmdt (res->p[0].p_pixels);
+    }
     return pic;
 }
diff --git a/modules/video_output/xcb/pictures.h b/modules/video_output/xcb/pictures.h
index ad14d4d..9cb2dea 100644
--- a/modules/video_output/xcb/pictures.h
+++ b/modules/video_output/xcb/pictures.h
@@ -34,7 +34,8 @@ bool XCB_shm_Check (vlc_object_t *obj, xcb_connection_t *conn);
 int XCB_picture_Alloc (vout_display_t *, picture_resource_t *, size_t size,
                        xcb_connection_t *, xcb_shm_seg_t);
 picture_t *XCB_picture_NewFromResource (const video_format_t *,
-                                        const picture_resource_t *);
+                                        const picture_resource_t *,
+                                        xcb_connection_t *);
 
 static inline xcb_shm_seg_t XCB_picture_GetSegment(const picture_t *pic)
 {
diff --git a/modules/video_output/xcb/x11.c b/modules/video_output/xcb/x11.c
index 62e8ed9..ea406a1 100644
--- a/modules/video_output/xcb/x11.c
+++ b/modules/video_output/xcb/x11.c
@@ -393,13 +393,10 @@ static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count)
 
         if (XCB_picture_Alloc (vd, &res, size, sys->conn, seg))
             break;
-        pic_array[count] = XCB_picture_NewFromResource (&vd->fmt, &res);
+        pic_array[count] = XCB_picture_NewFromResource (&vd->fmt, &res,
+                                                        sys->conn);
         if (unlikely(pic_array[count] == NULL))
-        {
-            if (seg != 0)
-                xcb_shm_detach (sys->conn, seg);
             break;
-        }
     }
     xcb_flush (sys->conn);
 
diff --git a/modules/video_output/xcb/xvideo.c b/modules/video_output/xcb/xvideo.c
index cf1353f..f3583c4 100644
--- a/modules/video_output/xcb/xvideo.c
+++ b/modules/video_output/xcb/xvideo.c
@@ -661,7 +661,8 @@ static void PoolAlloc (vout_display_t *vd, unsigned requested_count)
             res.p[1].p_pixels = buf;
         }
 
-        pic_array[count] = XCB_picture_NewFromResource (&vd->fmt, &res);
+        pic_array[count] = XCB_picture_NewFromResource (&vd->fmt, &res,
+                                                        p_sys->conn);
         if (unlikely(pic_array[count] == NULL))
             break;
     }



More information about the vlc-commits mailing list