Commit 89c0c777 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

XCB: factor segment detachment on error

parent 6d3bc51a
......@@ -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;
}
......@@ -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)
{
......
......@@ -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);
......
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment