Commit 77193c7b authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

XCB: develop picture free function

parent e1ee8b06
...@@ -147,16 +147,13 @@ int XCB_pictures_Alloc (vout_display_t *vd, picture_resource_t *res, ...@@ -147,16 +147,13 @@ int XCB_pictures_Alloc (vout_display_t *vd, picture_resource_t *res,
/** /**
* Release picture private data: detach the shared memory segment. * Release picture private data: detach the shared memory segment.
*/ */
void XCB_pictures_Free (picture_resource_t *res, xcb_connection_t *conn) void XCB_pictures_Free (void *mem)
{ {
#ifdef HAVE_SYS_SHM_H #ifdef HAVE_SYS_SHM_H
xcb_shm_seg_t segment = res->p_sys->segment; if (mem != NULL)
shmdt (mem);
if (conn != NULL && segment != 0)
xcb_shm_detach (conn, segment);
shmdt (res->p->p_pixels);
#else #else
free (res->p->p_pixels); free (mem);
#endif #endif
} }
...@@ -38,4 +38,4 @@ struct picture_sys_t ...@@ -38,4 +38,4 @@ struct picture_sys_t
}; };
int XCB_pictures_Alloc (vout_display_t *, picture_resource_t *, size_t size, int XCB_pictures_Alloc (vout_display_t *, picture_resource_t *, size_t size,
xcb_connection_t *, xcb_shm_seg_t); xcb_connection_t *, xcb_shm_seg_t);
void XCB_pictures_Free (picture_resource_t *, xcb_connection_t *); void XCB_pictures_Free (void *);
...@@ -396,7 +396,9 @@ static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count) ...@@ -396,7 +396,9 @@ static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count)
pic_array[count] = picture_NewFromResource (&vd->fmt, res); pic_array[count] = picture_NewFromResource (&vd->fmt, res);
if (!pic_array[count]) if (!pic_array[count])
{ {
XCB_pictures_Free (res, sys->conn); 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)); memset (res, 0, sizeof(*res));
break; break;
} }
...@@ -576,7 +578,9 @@ static void ResetPictures (vout_display_t *vd) ...@@ -576,7 +578,9 @@ static void ResetPictures (vout_display_t *vd)
if (!res->p->p_pixels) if (!res->p->p_pixels)
break; break;
XCB_pictures_Free (res, sys->conn); XCB_pictures_Free (res->p->p_pixels);
if (res->p_sys->segment)
xcb_shm_detach (sys->conn, res->p_sys->segment);
} }
picture_pool_Delete (sys->pool); picture_pool_Delete (sys->pool);
sys->pool = NULL; sys->pool = NULL;
......
...@@ -606,7 +606,7 @@ static void Close (vlc_object_t *obj) ...@@ -606,7 +606,7 @@ static void Close (vlc_object_t *obj)
if (!res->p->p_pixels) if (!res->p->p_pixels)
break; break;
XCB_pictures_Free (res, NULL); XCB_pictures_Free (res->p->p_pixels);
} }
picture_pool_Delete (p_sys->pool); picture_pool_Delete (p_sys->pool);
} }
...@@ -670,7 +670,9 @@ static void PoolAlloc (vout_display_t *vd, unsigned requested_count) ...@@ -670,7 +670,9 @@ static void PoolAlloc (vout_display_t *vd, unsigned requested_count)
pic_array[count] = picture_NewFromResource (&vd->fmt, res); pic_array[count] = picture_NewFromResource (&vd->fmt, res);
if (!pic_array[count]) if (!pic_array[count])
{ {
XCB_pictures_Free (res, p_sys->conn); XCB_pictures_Free (res->p->p_pixels);
if (res->p_sys->segment)
xcb_shm_detach (p_sys->conn, res->p_sys->segment);
memset (res, 0, sizeof(*res)); memset (res, 0, sizeof(*res));
break; 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