From: RĂ©mi Denis-Courmont Date: Wed, 2 Jun 2010 18:30:49 +0000 (+0300) Subject: --no-xlib: prevent use of XInitThreads() and hence Xlib X-Git-Tag: 1.2.0-pre1~6340 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=95c95cc91ac583b76582b63dfd6c95ca5fdde592;p=vlc --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. --- diff --git a/modules/audio_output/pulse.c b/modules/audio_output/pulse.c index f36ec0949e..a064ff3aec 100644 --- a/modules/audio_output/pulse.c +++ b/modules/audio_output/pulse.c @@ -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 */ diff --git a/modules/gui/hildon/maemo.c b/modules/gui/hildon/maemo.c index 14c51f6282..640069d55e 100644 --- a/modules/gui/hildon/maemo.c +++ b/modules/gui/hildon/maemo.c @@ -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 */ diff --git a/modules/gui/qt4/qt4.cpp b/modules/gui/qt4/qt4.cpp index 1e75a0866b..6d13f5bcec 100644 --- a/modules/gui/qt4/qt4.cpp +++ b/modules/gui/qt4/qt4.cpp @@ -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" ); diff --git a/modules/gui/skins2/x11/x11_factory.cpp b/modules/gui/skins2/x11/x11_factory.cpp index fa54582c1a..5d09402ba9 100644 --- a/modules/gui/skins2/x11/x11_factory.cpp +++ b/modules/gui/skins2/x11/x11_factory.cpp @@ -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() ); diff --git a/modules/video_output/xcb/glx.c b/modules/video_output/xcb/glx.c index f67d9f63eb..7598cd10f3 100644 --- a/modules/video_output/xcb/glx.c +++ b/modules/video_output/xcb/glx.c @@ -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; diff --git a/src/libvlc-module.c b/src/libvlc-module.c index 363c10254d..280db3fc59 100644 --- a/src/libvlc-module.c +++ b/src/libvlc-module.c @@ -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 */