]> git.sesse.net Git - vlc/commitdiff
Call XInitThreads early enough
authorRémi Denis-Courmont <remi@remlab.net>
Sun, 1 Mar 2009 11:41:46 +0000 (13:41 +0200)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 1 Mar 2009 11:41:46 +0000 (13:41 +0200)
We need to call XInitThreads before anyone tries XOpenDisplay or
something, and XInitThreads itself is not re-entrant, so call it before
we start LibVLC. This only "fixes" Xlib with VLC. Other LibVLC users
need to do something similar themselves. LibVLC cannot do it. Other
application may have already connected to X before it starts LibVLC.

bin/vlc.c
configure.ac

index 3a15722d77e4f8094a75c27784026f8e1c368721..5220618e07bfc4da03250d52e1f152218a1c7296 100644 (file)
--- a/bin/vlc.c
+++ b/bin/vlc.c
@@ -33,7 +33,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <locale.h>
-
+#ifdef HAVE_X11_XLIB_H
+# include <X11/Xlib.h>
+#endif
 
 /* Explicit HACK */
 extern void LocaleFree (const char *);
@@ -82,6 +84,15 @@ int main( int i_argc, const char *ppsz_argv[] )
 #   endif
 #endif
 
+#ifdef HAVE_X11_XLIB_H
+    /* Initialize Xlib thread support. */
+    if (!XInitThreads ())
+    {
+        fputs ("VLC requires a thread-safe Xlib. Sorry.\n", stderr);
+        return 1;
+    }
+#endif
+
     /* Synchronously intercepted POSIX signals.
      *
      * In a threaded program such as VLC, the only sane way to handle signals
index 8e34d401623c51dbaf42a57f809a8081316fe8b0..568932b7c264756fc27c59793dca654ffcb009a3 100644 (file)
@@ -3964,6 +3964,9 @@ AC_ARG_ENABLE(x11,
 
 CPPFLAGS="${CPPFLAGS_save} ${X_CFLAGS}"
 AC_CHECK_HEADERS(X11/Xlib.h, [
+  VLC_ADD_CPPFLAGS([vlc], [${X_CFLAGS}])
+  VLC_ADD_LIBS([vlc], [${X_LIBS} ${X_PRE_LIBS} -lX11])
+
   VLC_ADD_PLUGIN([screen])
   VLC_ADD_CPPFLAGS([screen],[${X_CFLAGS}])
   VLC_ADD_LIBS([screen],[${X_LIBS} ${X_PRE_LIBS} -lX11])