00001 /***************************************************************************** 00002 * vlc_xlib.h: initialization of Xlib 00003 ***************************************************************************** 00004 * Copyright (C) 2010 Rémi Denis-Courmont 00005 * 00006 * This program is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 2.1 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this program; if not, write to the Free Software Foundation, 00018 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. 00019 *****************************************************************************/ 00020 00021 #ifndef VLC_XLIB_H 00022 # define VLC_XLIB_H 1 00023 00024 # include <stdio.h> 00025 # include <stdlib.h> 00026 # include <X11/Xlib.h> 00027 # include <X11/Xlibint.h> 00028 00029 static inline bool vlc_xlib_init (vlc_object_t *obj) 00030 { 00031 if (!var_InheritBool (obj, "xlib")) 00032 return false; 00033 00034 bool ok = false; 00035 00036 /* XInitThreads() can be called multiple times, 00037 * but it is not reentrant, so we need this global lock. */ 00038 vlc_global_lock (VLC_XLIB_MUTEX); 00039 00040 if (_Xglobal_lock == NULL && unlikely(_XErrorFunction != NULL)) 00041 /* (_Xglobal_lock == NULL) => Xlib threads not initialized */ 00042 /* (_XErrorFunction != NULL) => Xlib already in use */ 00043 fprintf (stderr, "%s:%u:%s: Xlib not initialized for threads.\n" 00044 "This process is probably using LibVLC incorrectly.\n" 00045 "Pass \"--no-xlib\" to libvlc_new() to fix this.\n", 00046 __FILE__, __LINE__, __func__); 00047 else if (XInitThreads ()) 00048 ok = true; 00049 00050 vlc_global_unlock (VLC_XLIB_MUTEX); 00051 00052 if (!ok) 00053 msg_Err (obj, "Xlib not initialized for threads"); 00054 return ok; 00055 } 00056 00057 #endif
1.7.1