Merge pull request #2146 from MartijnKaijser/12584
[vuplus_xbmc] / xbmc / system.h
1 #pragma once
2
3 /*
4  *      Copyright (C) 2005-2013 Team XBMC
5  *      http://www.xbmc.org
6  *
7  *  This Program is free software; you can redistribute it and/or modify
8  *  it under the terms of the GNU General Public License as published by
9  *  the Free Software Foundation; either version 2, or (at your option)
10  *  any later version.
11  *
12  *  This Program is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  *  GNU General Public License for more details.
16  *
17  *  You should have received a copy of the GNU General Public License
18  *  along with XBMC; see the file COPYING.  If not, see
19  *  <http://www.gnu.org/licenses/>.
20  *
21  */
22
23 #if defined(HAVE_CONFIG_H) && !defined(TARGET_WINDOWS)
24 #include "config.h"
25 #define DECLARE_UNUSED(a,b) a __attribute__((unused)) b;
26 #endif
27
28 /*****************
29  * All platforms
30  *****************/
31 #define HAS_DVD_SWSCALE
32 #define HAS_DVDPLAYER
33 #define HAS_EVENT_SERVER
34 #define HAS_KARAOKE
35 #define HAS_SCREENSAVER
36 #define HAS_PYTHON
37 #define HAS_SYSINFO
38 #define HAS_VIDEO_PLAYBACK
39 #define HAS_VISUALISATION
40 #define HAS_PVRCLIENTS
41
42 #ifdef HAVE_LIBMICROHTTPD
43 #define HAS_WEB_SERVER
44 #define HAS_WEB_INTERFACE
45 #endif
46
47 #define HAS_JSONRPC
48
49 #ifdef USE_ASAP_CODEC
50 #define HAS_ASAP_CODEC
51 #endif
52
53 #define HAS_FILESYSTEM
54 #define HAS_FILESYSTEM_CDDA
55 #define HAS_FILESYSTEM_RTV
56 #define HAS_FILESYSTEM_DAAP
57 #define HAS_FILESYSTEM_SAP
58 #define HAS_FILESYSTEM_VTP
59 #define HAS_FILESYSTEM_HTSP
60
61 #ifdef HAVE_LIBSMBCLIENT
62   #define HAS_FILESYSTEM_SMB
63 #endif
64
65 #ifdef HAVE_LIBNFS
66   #define HAS_FILESYSTEM_NFS
67 #endif
68
69 #ifdef HAVE_LIBAFPCLIENT
70   #define HAS_FILESYSTEM_AFP
71 #endif
72
73 #ifdef HAVE_LIBPLIST
74   #define HAS_AIRPLAY
75 #endif
76
77 #ifdef HAVE_LIBSHAIRPORT
78   #define HAS_AIRTUNES
79 #endif
80
81 #ifdef HAVE_MYSQL
82   #define HAS_MYSQL
83 #endif
84
85 #if defined(USE_UPNP)
86   #define HAS_UPNP
87 #endif
88
89 /**********************
90  * Non-free Components
91  **********************/
92
93 #if defined(TARGET_WINDOWS)
94   #define HAS_FILESYSTEM_RAR
95 #else
96   #if defined(HAVE_XBMC_NONFREE)
97     #define HAS_FILESYSTEM_RAR
98   #endif
99 #endif
100
101 /*****************
102  * Win32 Specific
103  *****************/
104
105 #if defined(TARGET_WINDOWS)
106 #define HAS_SDL_JOYSTICK
107 #define HAS_DVD_DRIVE
108 #define HAS_WIN32_NETWORK
109 #define HAS_IRSERVERSUITE
110 #define HAS_AUDIO
111 #define HAVE_LIBCRYSTALHD 2
112 #define HAS_WEB_SERVER
113 #define HAS_WEB_INTERFACE
114 #define HAVE_LIBSSH
115 #define HAS_LIBRTMP
116 #define HAVE_LIBBLURAY
117 #define HAS_ASAP_CODEC
118 #define HAVE_YAJL_YAJL_VERSION_H
119 #define HAS_FILESYSTEM_SMB
120 #define HAS_FILESYSTEM_NFS
121 #define HAS_ZEROCONF
122 #define HAS_AIRPLAY
123 #define HAS_AIRTUNES
124 #define HAVE_LIBCEC
125 #define HAVE_LIBMP3LAME
126 #define HAVE_LIBVORBISENC
127 #define HAS_MYSQL
128 #define HAS_UPNP
129
130 #define DECLARE_UNUSED(a,b) a b;
131 #endif
132
133 /*****************
134  * Mac Specific
135  *****************/
136
137 #if defined(TARGET_DARWIN)
138   #if defined(TARGET_DARWIN_OSX)
139     #define HAS_GL
140     #define HAS_SDL
141     #define HAS_SDL_OPENGL
142     #define HAS_SDL_WIN_EVENTS
143   #endif
144   #define HAS_ZEROCONF
145   #define HAS_LINUX_NETWORK
146 #endif
147
148 /*****************
149  * Linux Specific
150  *****************/
151
152 #if defined(TARGET_LINUX) || defined(TARGET_FREEBSD)
153 #if defined(HAVE_LIBAVAHI_COMMON) && defined(HAVE_LIBAVAHI_CLIENT)
154 #define HAS_ZEROCONF
155 #define HAS_AVAHI
156 #endif
157 #ifdef HAVE_DBUS
158 #define HAS_DBUS
159 #endif
160 #define HAS_GL
161 #ifdef HAVE_X11
162 #define HAS_GLX
163 #endif
164 #ifdef HAVE_SDL
165 #define HAS_SDL
166 #ifndef HAS_SDL_OPENGL
167 #define HAS_SDL_OPENGL
168 #endif
169 #define HAS_SDL_WIN_EVENTS
170 #else
171 #define HAS_LINUX_EVENTS
172 #endif
173 #define HAS_LINUX_NETWORK
174 #define HAS_LIRC
175 #ifdef HAVE_LIBPULSE
176 #define HAS_PULSEAUDIO
177 #endif
178 #ifdef HAVE_LIBXRANDR
179 #define HAS_XRANDR
180 #endif
181 #ifdef HAVE_ALSA
182 #define HAS_ALSA
183 #endif
184 #endif
185
186 #ifdef HAVE_LIBSSH
187 #define HAS_FILESYSTEM_SFTP
188 #endif
189
190 /*****************
191  * Git revision
192  *****************/
193
194 #if defined(TARGET_DARWIN)
195 #include "../git_revision.h"
196 #endif
197
198 #ifndef GIT_REV
199 #define GIT_REV "Unknown"
200 #endif
201
202 /****************************************
203  * Additional platform specific includes
204  ****************************************/
205
206 #if defined(TARGET_WINDOWS)
207 #include <windows.h>
208 #define DIRECTINPUT_VERSION 0x0800
209 #include "mmsystem.h"
210 #include "DInput.h"
211 #include "DSound.h"
212 #define DSSPEAKER_USE_DEFAULT DSSPEAKER_STEREO
213 #define LPDIRECTSOUND8 LPDIRECTSOUND
214 #undef GetFreeSpace
215 #include "PlatformInclude.h"
216 #ifdef HAS_DX
217 #include "D3D9.h"   // On Win32, we're always using DirectX for something, whether it be the actual rendering
218 #include "D3DX9.h"  // or the reference video clock.
219 #else
220 #include <d3d9types.h>
221 #endif
222 #ifdef HAS_SDL
223 #include "SDL\SDL.h"
224 #endif
225 #endif
226
227 #if defined(TARGET_POSIX)
228 #include <time.h>
229 #include <sys/time.h>
230 #include <sys/types.h>
231 #include <errno.h>
232 #include "PlatformInclude.h"
233 #endif
234
235 #if defined(TARGET_ANDROID)
236 #undef HAS_LINUX_EVENTS
237 #undef HAS_LIRC
238 #endif
239
240 // EGL detected. Dont use GLX!
241 #ifdef HAVE_LIBEGL
242 #undef HAS_GLX
243 #define HAS_EGL
244 #endif
245
246 // GLES2.0 detected. Dont use GL!
247 #ifdef HAVE_LIBGLESV2
248 #undef HAS_GL
249 #define HAS_GLES 2
250 #endif
251
252 // GLES1.0 detected. Dont use GL!
253 #ifdef HAVE_LIBGLES
254 #undef HAS_GL
255 #define HAS_GLES 1
256 #endif
257
258 #ifdef HAS_DVD_DRIVE
259 #define HAS_CDDA_RIPPER
260 #endif
261
262 #define SAFE_DELETE(p)       do { delete (p);     (p)=NULL; } while (0)
263 #define SAFE_DELETE_ARRAY(p) do { delete[] (p);   (p)=NULL; } while (0)
264 #define SAFE_RELEASE(p)      do { if(p) { (p)->Release(); (p)=NULL; } } while (0)
265
266 // Useful pixel colour manipulation macros
267 #define GET_A(color)            ((color >> 24) & 0xFF)
268 #define GET_R(color)            ((color >> 16) & 0xFF)
269 #define GET_G(color)            ((color >>  8) & 0xFF)
270 #define GET_B(color)            ((color >>  0) & 0xFF)
271