]> git.sesse.net Git - vlc/commitdiff
XCB: factor segment detachment on error
authorRémi Denis-Courmont <remi@remlab.net>
Sat, 4 Oct 2014 08:53:17 +0000 (11:53 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sat, 4 Oct 2014 09:19:22 +0000 (12:19 +0300)
modules/video_output/xcb/pictures.c
modules/video_output/xcb/pictures.h
modules/video_output/xcb/x11.c
modules/video_output/xcb/xvideo.c

index b2c1fceea844f5711eabc7c3cd6563fe4a6c6cae..ed449bfa0fc8e8c01778c344dbff7ae1a17e35d3 100644 (file)
@@ -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;
 }
index ad14d4dd277e8175501dd552222e1bfdc382d78b..9cb2deae2437a6ad813e3169b6362efd5d14c8d4 100644 (file)
@@ -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)
 {
index 62e8ed9318fed9e9c6a8dbe41a09ee5de7c15482..ea406a1d1770c330bbf7c4a3c3c7e32bd1193aa4 100644 (file)
@@ -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);
 
index cf1353fae3c481d499f8bdb9b33ed2194c957d71..f3583c49986f8c35181e61eca0e571766440331f 100644 (file)
@@ -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;
     }