[vlc-commits] XCB: pass shared memory segment XID as parameter of picture allocation
Rémi Denis-Courmont
git at videolan.org
Sat Jul 13 22:43:20 CEST 2013
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sat Jul 13 23:01:50 2013 +0300| [792f9eb5ba48319d40d9a9776c70c0c8957b18e0] | committer: Rémi Denis-Courmont
XCB: pass shared memory segment XID as parameter of picture allocation
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=792f9eb5ba48319d40d9a9776c70c0c8957b18e0
---
modules/video_output/xcb/pictures.c | 17 +++++------------
modules/video_output/xcb/pictures.h | 2 +-
modules/video_output/xcb/x11.c | 3 ++-
modules/video_output/xcb/xvideo.c | 3 ++-
4 files changed, 10 insertions(+), 15 deletions(-)
diff --git a/modules/video_output/xcb/pictures.c b/modules/video_output/xcb/pictures.c
index 8efc5bb..d748b86 100644
--- a/modules/video_output/xcb/pictures.c
+++ b/modules/video_output/xcb/pictures.c
@@ -71,7 +71,8 @@ bool XCB_shm_Check (vlc_object_t *obj, xcb_connection_t *conn)
* the X server (MIT-SHM extension).
*/
int XCB_pictures_Alloc (vout_display_t *vd, picture_resource_t *res,
- size_t size, xcb_connection_t *conn, bool attach)
+ size_t size, xcb_connection_t *conn,
+ xcb_shm_seg_t segment)
{
res->p_sys = malloc (sizeof(*res->p_sys));
if (!res->p_sys)
@@ -97,15 +98,9 @@ int XCB_pictures_Alloc (vout_display_t *vd, picture_resource_t *res,
return VLC_EGENERIC;
}
- xcb_shm_seg_t segment;
- if (attach)
- {
- /* Attach the segment to X */
- xcb_void_cookie_t ck;
-
- segment = xcb_generate_id (conn);
- ck = xcb_shm_attach_checked (conn, segment, id, 1);
-
+ if (segment != 0)
+ { /* Attach the segment to X */
+ xcb_void_cookie_t ck = xcb_shm_attach_checked (conn, segment, id, 1);
switch (XCB_error_Check (vd, conn, "shared memory server-side error",
ck))
{
@@ -130,8 +125,6 @@ int XCB_pictures_Alloc (vout_display_t *vd, picture_resource_t *res,
segment = 0;
}
}
- else
- segment = 0;
shmctl (id, IPC_RMID, NULL);
res->p_sys->segment = segment;
diff --git a/modules/video_output/xcb/pictures.h b/modules/video_output/xcb/pictures.h
index 9ee54c7..ffd4970 100644
--- a/modules/video_output/xcb/pictures.h
+++ b/modules/video_output/xcb/pictures.h
@@ -37,5 +37,5 @@ struct picture_sys_t
xcb_shm_seg_t segment;
};
int XCB_pictures_Alloc (vout_display_t *, picture_resource_t *, size_t size,
- xcb_connection_t *, bool attach);
+ xcb_connection_t *, xcb_shm_seg_t);
void XCB_pictures_Free (picture_resource_t *, xcb_connection_t *);
diff --git a/modules/video_output/xcb/x11.c b/modules/video_output/xcb/x11.c
index 1a6864f..f0fcfcb 100644
--- a/modules/video_output/xcb/x11.c
+++ b/modules/video_output/xcb/x11.c
@@ -384,7 +384,8 @@ static picture_pool_t *Pool (vout_display_t *vd, unsigned requested_count)
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->shm))
+ sys->conn,
+ sys->shm ? xcb_generate_id(sys->conn) : 0))
break;
pic_array[count] = picture_NewFromResource (&vd->fmt, res);
if (!pic_array[count])
diff --git a/modules/video_output/xcb/xvideo.c b/modules/video_output/xcb/xvideo.c
index 31cccae..77f96a6 100644
--- a/modules/video_output/xcb/xvideo.c
+++ b/modules/video_output/xcb/xvideo.c
@@ -640,6 +640,7 @@ static void PoolAlloc (vout_display_t *vd, unsigned requested_count)
for (count = 0; count < requested_count; count++)
{
picture_resource_t *res = &p_sys->resource[count];
+ xcb_shm_seg_t seg = p_sys->shm ? xcb_generate_id (p_sys->conn) : 0;
for (unsigned i = 0; i < num_planes; i++)
{
@@ -651,7 +652,7 @@ static void PoolAlloc (vout_display_t *vd, unsigned requested_count)
}
if (XCB_pictures_Alloc (vd, res, p_sys->att->data_size,
- p_sys->conn, p_sys->shm))
+ p_sys->conn, seg))
break;
/* Allocate further planes as specified by XVideo */
More information about the vlc-commits
mailing list