Commit ffe7e8d1 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont
Browse files

Split MIT-SHM check out of GetWindow

parent 719ee562
......@@ -86,14 +86,12 @@ static xcb_connection_t *Connect (vlc_object_t *obj, const char *display)
/**
* Create a VLC video X window object, connect to the corresponding X server,
* find the corresponding X server screen,
* and probe the MIT-SHM extension.
* find the corresponding X server screen.
*/
vout_window_t *GetWindow (vout_display_t *vd,
xcb_connection_t **restrict pconn,
const xcb_screen_t **restrict pscreen,
uint8_t *restrict pdepth,
bool *restrict pshm)
uint8_t *restrict pdepth)
{
/* Get window */
xcb_window_t root;
......@@ -166,27 +164,8 @@ vout_window_t *GetWindow (vout_display_t *vd,
}
msg_Dbg (vd, "using screen 0x%"PRIx32, root);
/* Check MIT-SHM shared memory support */
bool shm = var_CreateGetBool (vd, "x11-shm") > 0;
if (shm)
{
xcb_shm_query_version_cookie_t ck;
xcb_shm_query_version_reply_t *r;
ck = xcb_shm_query_version (conn);
r = xcb_shm_query_version_reply (conn, ck, NULL);
if (!r)
{
msg_Err (vd, "shared memory (MIT-SHM) not available");
msg_Warn (vd, "display will be slow");
shm = false;
}
free (r);
}
*pconn = conn;
*pscreen = screen;
*pshm = shm;
return wnd;
error:
......@@ -213,6 +192,28 @@ int GetWindowSize (struct vout_window_t *wnd, xcb_connection_t *conn,
return 0;
}
/** Check MIT-SHM shared memory support */
void CheckSHM (vlc_object_t *obj, xcb_connection_t *conn, bool *restrict pshm)
{
bool shm = var_CreateGetBool (obj, "x11-shm") > 0;
if (shm)
{
xcb_shm_query_version_cookie_t ck;
xcb_shm_query_version_reply_t *r;
ck = xcb_shm_query_version (conn);
r = xcb_shm_query_version_reply (conn, ck, NULL);
if (!r)
{
msg_Err (obj, "shared memory (MIT-SHM) not available");
msg_Warn (obj, "display will be slow");
shm = false;
}
free (r);
}
*pshm = shm;
}
/**
* Create a blank cursor.
* Note that the pixmaps are leaked (until the X disconnection). Hence, this
......
......@@ -105,8 +105,7 @@ static int Open (vlc_object_t *obj)
/* Get window, connect to X server */
const xcb_screen_t *scr;
p_sys->embed = GetWindow (vd, &p_sys->conn, &scr, &p_sys->depth,
&p_sys->shm);
p_sys->embed = GetWindow (vd, &p_sys->conn, &scr, &p_sys->depth);
if (p_sys->embed == NULL)
{
free (p_sys);
......@@ -272,6 +271,8 @@ static int Open (vlc_object_t *obj)
p_sys->visible = false;
CheckSHM (obj, p_sys->conn, &p_sys->shm);
/* */
vout_display_info_t info = vd->info;
info.has_pictures_invalid = true;
......
......@@ -41,10 +41,10 @@ int ProcessKeyEvent (key_handler_t *, xcb_generic_event_t *);
struct vout_window_t *GetWindow (vout_display_t *obj,
xcb_connection_t **restrict pconn,
const xcb_screen_t **restrict pscreen,
uint8_t *restrict pdepth,
bool *restrict pshm);
uint8_t *restrict pdepth);
int GetWindowSize (struct vout_window_t *wnd, xcb_connection_t *conn,
unsigned *restrict width, unsigned *restrict height);
void CheckSHM (vlc_object_t *obj, xcb_connection_t *conn, bool *restrict pshm);
xcb_cursor_t CreateBlankCursor (xcb_connection_t *, const xcb_screen_t *);
int CheckError (vout_display_t *, xcb_connection_t *conn,
......
......@@ -301,7 +301,7 @@ static int Open (vlc_object_t *obj)
xcb_connection_t *conn;
const xcb_screen_t *screen;
uint8_t depth;
p_sys->embed = GetWindow (vd, &conn, &screen, &depth, &p_sys->shm);
p_sys->embed = GetWindow (vd, &conn, &screen, &depth);
if (p_sys->embed == NULL)
{
free (p_sys);
......@@ -501,7 +501,7 @@ static int Open (vlc_object_t *obj)
/* Create cursor */
p_sys->cursor = CreateBlankCursor (conn, screen);
/* */
CheckSHM (obj, conn, &p_sys->shm);
/* */
vout_display_info_t info = vd->info;
......
Supports Markdown
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