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

XCB: support platforms without System V shared memory (untested)

parent eab76644
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
#include <assert.h> #include <assert.h>
#include <sys/types.h> #include <sys/types.h>
#ifdef HAVE_SYS_SHM_H
#include <sys/shm.h> #include <sys/shm.h>
#endif
#include <xcb/xcb.h> #include <xcb/xcb.h>
#include <xcb/shm.h> #include <xcb/shm.h>
...@@ -160,6 +162,7 @@ error: ...@@ -160,6 +162,7 @@ error:
/** Check MIT-SHM shared memory support */ /** Check MIT-SHM shared memory support */
void CheckSHM (vlc_object_t *obj, xcb_connection_t *conn, bool *restrict pshm) void CheckSHM (vlc_object_t *obj, xcb_connection_t *conn, bool *restrict pshm)
{ {
#ifdef HAVE_SYS_SHM_H
bool shm = var_InheritBool (obj, "x11-shm") > 0; bool shm = var_InheritBool (obj, "x11-shm") > 0;
if (shm) if (shm)
{ {
...@@ -177,6 +180,11 @@ void CheckSHM (vlc_object_t *obj, xcb_connection_t *conn, bool *restrict pshm) ...@@ -177,6 +180,11 @@ void CheckSHM (vlc_object_t *obj, xcb_connection_t *conn, bool *restrict pshm)
free (r); free (r);
} }
*pshm = shm; *pshm = shm;
#else
msg_Warn (obj, "shared memory (MIT-SHM) not implemented");
(void) conn;
*pshm = false;
#endif
} }
/** /**
...@@ -191,6 +199,7 @@ int PictureResourceAlloc (vout_display_t *vd, picture_resource_t *res, size_t si ...@@ -191,6 +199,7 @@ int PictureResourceAlloc (vout_display_t *vd, picture_resource_t *res, size_t si
if (!res->p_sys) if (!res->p_sys)
return VLC_EGENERIC; return VLC_EGENERIC;
#ifdef HAVE_SYS_SHM_H
/* Allocate shared memory segment */ /* Allocate shared memory segment */
int id = shmget (IPC_PRIVATE, size, IPC_CREAT | 0700); int id = shmget (IPC_PRIVATE, size, IPC_CREAT | 0700);
if (id == -1) if (id == -1)
...@@ -231,6 +240,18 @@ int PictureResourceAlloc (vout_display_t *vd, picture_resource_t *res, size_t si ...@@ -231,6 +240,18 @@ int PictureResourceAlloc (vout_display_t *vd, picture_resource_t *res, size_t si
shmctl (id, IPC_RMID, 0); shmctl (id, IPC_RMID, 0);
res->p_sys->segment = segment; res->p_sys->segment = segment;
res->p->p_pixels = shm; res->p->p_pixels = shm;
#else
assert (!attach);
res->p_sys->segment = 0;
/* XXX: align on 32 bytes for VLC chroma filters */
res->p->p_pixels = malloc (size);
if (unlikely(res->p->p_pixels == NULL))
{
free (res->p_sys);
return VLC_EGENERIC;
}
#endif
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -239,10 +260,14 @@ int PictureResourceAlloc (vout_display_t *vd, picture_resource_t *res, size_t si ...@@ -239,10 +260,14 @@ int PictureResourceAlloc (vout_display_t *vd, picture_resource_t *res, size_t si
*/ */
void PictureResourceFree (picture_resource_t *res, xcb_connection_t *conn) void PictureResourceFree (picture_resource_t *res, xcb_connection_t *conn)
{ {
#ifdef HAVE_SYS_SHM_H
xcb_shm_seg_t segment = res->p_sys->segment; xcb_shm_seg_t segment = res->p_sys->segment;
if (conn != NULL && segment != 0) if (conn != NULL && segment != 0)
xcb_shm_detach (conn, segment); xcb_shm_detach (conn, segment);
shmdt (res->p->p_pixels); shmdt (res->p->p_pixels);
#else
free (res->p->p_pixels);
#endif
} }
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