]> git.sesse.net Git - vlc/commitdiff
--no-xlib: prevent use of XInitThreads() and hence Xlib
authorRémi Denis-Courmont <remi@remlab.net>
Wed, 2 Jun 2010 18:30:49 +0000 (21:30 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Wed, 2 Jun 2010 18:30:49 +0000 (21:30 +0300)
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.

modules/audio_output/pulse.c
modules/gui/hildon/maemo.c
modules/gui/qt4/qt4.cpp
modules/gui/skins2/x11/x11_factory.cpp
modules/video_output/xcb/glx.c
src/libvlc-module.c

index f36ec0949e6233c87e43b29ca842b05005535873..a064ff3aec0ef5307a143a16a3bd1d2a74255e7c 100644 (file)
@@ -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 */
index 14c51f628225f08d7948c55c9fc9756ecf0025b8..640069d55e7cca4549aa56c8b1ee1f21a06f6af3 100644 (file)
@@ -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 */
index 1e75a0866bea667ff3fdcc3b7fedcdeeea6d8ad6..6d13f5bcec57ba18ede305691ced066146548c1a 100644 (file)
@@ -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" );
index fa54582c1a609b7e3a58992dc605a847925249fe..5d09402ba99324738a2d375d9f344e79d46103b0 100644 (file)
@@ -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() );
index f67d9f63eb1be713cd78852a7d7f53b78d2fabd2..7598cd10f3b3ec02e60f83df3c7bf73eb4efbb9a 100644 (file)
@@ -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;
index 363c10254d943b3c5869e554cb2a65c1328b987d..280db3fc5988ba1d8bf53fda2b60eeb7bac63f7f 100644 (file)
@@ -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 */