Commit 74a2179e authored by Jean-Paul Saman's avatar Jean-Paul Saman

Revert "VAAPI XCB: Move XOpenDisplay/XCloseDisplay to libva connection struct."

This reverts commit 96640312acefdfdd70ded1773353e34e85a3b637.
parent 0d6542ef
...@@ -130,7 +130,6 @@ static void vlc_va_destroy_surfaces( vlc_va_conn_t *conn ) ...@@ -130,7 +130,6 @@ static void vlc_va_destroy_surfaces( vlc_va_conn_t *conn )
/* Global VAAPI connection state */ /* Global VAAPI connection state */
static vlc_va_conn_t vlc_va_conn = { static vlc_va_conn_t vlc_va_conn = {
.x11 = NULL,
.p_display = 0, .p_display = 0,
/* libva version */ /* libva version */
.i_version_major = 0, .i_version_major = 0,
...@@ -154,7 +153,7 @@ static vlc_va_conn_t *vlc_va_get_conn( void ) ...@@ -154,7 +153,7 @@ static vlc_va_conn_t *vlc_va_get_conn( void )
return (vlc_va_conn_t *) &vlc_va_conn; return (vlc_va_conn_t *) &vlc_va_conn;
} }
vlc_va_conn_t *vlc_va_Initialize( const char *display ) vlc_va_conn_t *vlc_va_Initialize( Display *display )
{ {
vlc_mutex_lock( &vlc_va_conn_lock ); vlc_mutex_lock( &vlc_va_conn_lock );
...@@ -168,13 +167,8 @@ vlc_va_conn_t *vlc_va_Initialize( const char *display ) ...@@ -168,13 +167,8 @@ vlc_va_conn_t *vlc_va_Initialize( const char *display )
return conn; return conn;
} }
/* X11 display */
conn->x11 = XOpenDisplay(display);
if( !conn->x11 )
goto error;
/* Create a VA display */ /* Create a VA display */
conn->p_display = vaGetDisplay(conn->x11); conn->p_display = vaGetDisplay(display);
if( !conn->p_display ) if( !conn->p_display )
goto error; goto error;
...@@ -186,8 +180,6 @@ vlc_va_conn_t *vlc_va_Initialize( const char *display ) ...@@ -186,8 +180,6 @@ vlc_va_conn_t *vlc_va_Initialize( const char *display )
return conn; return conn;
error: error:
if( conn->x11 )
XCloseDisplay( conn->x11 );
vlc_mutex_unlock( &vlc_va_conn_lock ); vlc_mutex_unlock( &vlc_va_conn_lock );
return NULL; return NULL;
} }
...@@ -206,10 +198,8 @@ void vlc_va_Terminate( vlc_va_conn_t *conn ) ...@@ -206,10 +198,8 @@ void vlc_va_Terminate( vlc_va_conn_t *conn )
assert( conn->p_display ); assert( conn->p_display );
vaTerminate( conn->p_display ); vaTerminate( conn->p_display );
XCloseDisplay( conn->x11 );
/* Reset values */ /* Reset values */
conn->x11 = NULL;
conn->p_display = 0; conn->p_display = 0;
conn->i_version_major = conn->i_version_minor = 0; conn->i_version_major = conn->i_version_minor = 0;
conn->i_ref_count = 0; conn->i_ref_count = 0;
......
...@@ -55,6 +55,7 @@ typedef struct ...@@ -55,6 +55,7 @@ typedef struct
/* */ /* */
vlc_va_conn_t *conn; vlc_va_conn_t *conn;
Display *display;
VAConfigID i_config_id; VAConfigID i_config_id;
VAContextID i_context_id; VAContextID i_context_id;
...@@ -133,7 +134,11 @@ static int Open( vlc_va_vaapi_t *p_va, int i_codec_id, int i_count ) ...@@ -133,7 +134,11 @@ static int Open( vlc_va_vaapi_t *p_va, int i_codec_id, int i_count )
p_va->image.image_id = VA_INVALID_ID; p_va->image.image_id = VA_INVALID_ID;
/* Create a VA display */ /* Create a VA display */
p_va->conn = vlc_va_Initialize(NULL); p_va->display = XOpenDisplay(NULL);
if (!p_va->display)
goto error;
p_va->conn = vlc_va_Initialize(p_va->display);
if (!p_va->conn) if (!p_va->conn)
goto error; goto error;
...@@ -570,6 +575,10 @@ static void Close( vlc_va_vaapi_t *p_va ) ...@@ -570,6 +575,10 @@ static void Close( vlc_va_vaapi_t *p_va )
vlc_va_Terminate( p_va->conn ); vlc_va_Terminate( p_va->conn );
} }
#if 0 /* FIXME: workaround for ATI and AMD graphics GPU */
if( p_va->display )
XCloseDisplay( p_va->display );
#endif
} }
static void Delete( vlc_va_t *p_external ) static void Delete( vlc_va_t *p_external )
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
typedef struct vlc_va_conn_t vlc_va_conn_t; typedef struct vlc_va_conn_t vlc_va_conn_t;
struct vlc_va_conn_t struct vlc_va_conn_t
{ {
Display *x11; /* x11 display connection */
VADisplay p_display; VADisplay p_display;
int i_version_major; int i_version_major;
int i_version_minor; int i_version_minor;
...@@ -52,7 +51,7 @@ struct vlc_va_conn_t ...@@ -52,7 +51,7 @@ struct vlc_va_conn_t
}; };
/* Initialize shared connection to libva */ /* Initialize shared connection to libva */
vlc_va_conn_t *vlc_va_Initialize(const char *display); vlc_va_conn_t *vlc_va_Initialize(Display *display);
/* Deinitialize shared connection to libva */ /* Deinitialize shared connection to libva */
void vlc_va_Terminate(vlc_va_conn_t *conn); void vlc_va_Terminate(vlc_va_conn_t *conn);
......
...@@ -93,6 +93,7 @@ struct vout_display_sys_t ...@@ -93,6 +93,7 @@ struct vout_display_sys_t
vlc_mutex_t cache_lock; vlc_mutex_t cache_lock;
vlc_array_t cache; /* array of subpicture_subpicture_cache_t */ vlc_array_t cache; /* array of subpicture_subpicture_cache_t */
Display *x11display; /* x11 display connection */
xcb_cursor_t cursor; /* blank cursor */ xcb_cursor_t cursor; /* blank cursor */
xcb_window_t window; /* drawable X window */ xcb_window_t window; /* drawable X window */
...@@ -228,18 +229,25 @@ int OpenVaapiX11(vlc_object_t *obj) ...@@ -228,18 +229,25 @@ int OpenVaapiX11(vlc_object_t *obj)
if (unlikely(sys->embed == NULL)) if (unlikely(sys->embed == NULL))
goto error; goto error;
/* Create a VA display */
sys->vaconn = vlc_va_Initialize(sys->embed->display.x11);
if (!sys->vaconn)
goto error;
/* Connect to X server */ /* Connect to X server */
xcb_connection_t *conn = xcb_connect(sys->embed->display.x11, NULL); xcb_connection_t *conn = xcb_connect(sys->embed->display.x11, NULL);
if (unlikely(xcb_connection_has_error (conn))) if (unlikely(xcb_connection_has_error (conn)))
goto error; goto error;
/* X11 display */
sys->x11display = XOpenDisplay(sys->embed->display.x11);
if (!sys->x11display)
{
xcb_disconnect(conn);
goto error;
}
sys->conn = conn; sys->conn = conn;
/* Create a VA display */
sys->vaconn = vlc_va_Initialize(sys->x11display);
if (!sys->vaconn)
goto error;
vlc_fourcc_t i_chroma; vlc_fourcc_t i_chroma;
int32_t i_bits_per_pixel; int32_t i_bits_per_pixel;
if (FindVAFourCC(sys->vaconn, &sys->img_fmt, &i_chroma, &i_bits_per_pixel) != VLC_SUCCESS) if (FindVAFourCC(sys->vaconn, &sys->img_fmt, &i_chroma, &i_bits_per_pixel) != VLC_SUCCESS)
...@@ -248,7 +256,7 @@ int OpenVaapiX11(vlc_object_t *obj) ...@@ -248,7 +256,7 @@ int OpenVaapiX11(vlc_object_t *obj)
vd->fmt.i_chroma = i_chroma; vd->fmt.i_chroma = i_chroma;
vd->fmt.i_bits_per_pixel = i_bits_per_pixel; vd->fmt.i_bits_per_pixel = i_bits_per_pixel;
XSetEventQueueOwner(sys->vaconn->x11, XCBOwnsEventQueue); XSetEventQueueOwner(sys->x11display, XCBOwnsEventQueue);
RegisterMouseEvents(obj, conn, sys->embed->handle.xid); RegisterMouseEvents(obj, conn, sys->embed->handle.xid);
...@@ -369,6 +377,9 @@ void CloseVaapiX11(vlc_object_t *obj) ...@@ -369,6 +377,9 @@ void CloseVaapiX11(vlc_object_t *obj)
xcb_disconnect(sys->conn); xcb_disconnect(sys->conn);
} }
if (sys->x11display)
XCloseDisplay(sys->x11display);
if (sys->embed) if (sys->embed)
vout_display_DeleteWindow (vd, sys->embed); vout_display_DeleteWindow (vd, sys->embed);
......
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