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

--no-xlib: prevent use of XInitThreads() and hence Xlib

Certain LibVLC applications fail to call XInitThreads() before they
call XOpenDisplay(). Then VLC calls XInitThreads(). Then the
applications call XCloseDisplay(), which raises a segmentation fault.
In this case, Xlib tries acquire lock that was never created as the
Display ppinter was created before threaded Xlib mode was enabled.

These applications can now pass --no-xlib to libvlc_new(). This will
prevent any VLC Xlib-based plugin from being used. Currently, this
affects interfaces (not really an issue), PulseAudio (until Colin's
patch is merged upstream) and GLX (Xlib-based by design).

This will be necessary to address #3662.
parent b4b9d384
......@@ -124,7 +124,7 @@ static int Open ( vlc_object_t *p_this )
#ifdef X_DISPLAY_MISSING
# error Xlib required due to PulseAudio bug 799!
#else
if( !XInitThreads() )
if( !var_InheritBool( p_this, "xlib" ) || !XInitThreads() )
return VLC_EGENERIC;
#endif
/* Allocate structures */
......
......@@ -80,7 +80,7 @@ static int Open( vlc_object_t *p_this )
intf_sys_t *p_sys;
vlc_value_t val;
if( !XInitThreads() )
if( !var_InheritBool( p_this, "xlib" ) || !XInitThreads() )
return VLC_EGENERIC;
/* Allocate instance and initialize some members */
......
......@@ -283,7 +283,7 @@ static int Open( vlc_object_t *p_this, bool isDialogProvider )
intf_thread_t *p_intf = (intf_thread_t *)p_this;
#ifdef Q_WS_X11
if( !XInitThreads() )
if( !var_InheritBool( p_this, "xlib" ) || !XInitThreads() )
return VLC_EGENERIC;
char *display = var_CreateGetNonEmptyString( p_intf, "x11-display" );
......
......@@ -57,8 +57,11 @@ X11Factory::~X11Factory()
bool X11Factory::init()
{
// make sure xlib is safe-thread
if( !XInitThreads() )
if( !var_InheritBool( getIntf(), "xlib" ) || !XInitThreads() )
{
msg_Err( getIntf(), "initializing xlib for multi-threading failed" );
return false;
}
// Create the X11 display
m_pDisplay = new X11Display( getIntf() );
......
......@@ -203,7 +203,7 @@ static int CreateWindow (vout_display_t *vd, xcb_connection_t *conn,
*/
static int Open (vlc_object_t *obj)
{
if (!XInitThreads ())
if (!var_InheritBool (obj, "xlib") || !XInitThreads ())
return VLC_EGENERIC;
vout_display_t *vd = (vout_display_t *)obj;
......
......@@ -1641,6 +1641,8 @@ vlc_module_begin ()
DISPLAY_TEXT, DISPLAY_LONGTEXT, true )
add_deprecated_alias( "xvideo-display" ) /* deprecated since 1.1.0 */
add_deprecated_alias( "glx-display" )
add_bool( "xlib", true, NULL, "", "", true )
change_private ()
add_bool( "drop-late-frames", 1, NULL, DROP_LATE_FRAMES_TEXT,
DROP_LATE_FRAMES_LONGTEXT, true )
/* Used in vout_synchro */
......
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