|
1 /* |
|
2 * OpenAL Bridge - a simple portable library for OpenAL interface |
|
3 * Copyright (c) 2009 Vittorio Giovara <vittorio.giovara@gmail.com> |
|
4 * |
|
5 * This program is free software; you can redistribute it and/or modify |
|
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation; version 2 of the License |
|
8 * |
|
9 * This program is distributed in the hope that it will be useful, |
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 * GNU Lesser General Public License for more details. |
|
13 * |
|
14 * You should have received a copy of the GNU Lesser General Public License |
|
15 * along with this program; if not, write to the Free Software |
|
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 */ |
|
18 |
|
19 #ifndef _OALB_GLOBALS_H |
|
20 #define _OALB_GLOBALS_H |
|
21 |
|
22 #include <stdio.h> |
|
23 #include <stdlib.h> |
|
24 #include "al.h" |
|
25 |
|
26 #ifndef _WIN32 |
|
27 #include <pthread.h> |
|
28 #include <syslog.h> |
|
29 #else |
|
30 #include <process.h> |
|
31 #endif |
|
32 |
|
33 |
|
34 // 1.0 02/03/10 - Defines cross-platform sleep, usleep, etc. [Wu Yongwei] |
|
35 #ifndef _SLEEP_H |
|
36 #define _SLEEP_H |
|
37 #ifdef _WIN32 |
|
38 # if defined(_NEED_SLEEP_ONLY) && (defined(_MSC_VER) || defined(__MINGW32__)) |
|
39 # include <stdlib.h> |
|
40 # define sleep(t) _sleep((t) * 1000) |
|
41 # else |
|
42 # define WIN32_LEAN_AND_MEAN |
|
43 # include <windows.h> |
|
44 # define sleep(t) Sleep((t) * 1000) |
|
45 # endif |
|
46 # ifndef _NEED_SLEEP_ONLY |
|
47 # define msleep(t) Sleep(t) |
|
48 # define usleep(t) Sleep((t) / 1000) |
|
49 # endif |
|
50 #else |
|
51 # include <unistd.h> |
|
52 # ifndef _NEED_SLEEP_ONLY |
|
53 # define msleep(t) usleep((t) * 1000) |
|
54 # endif |
|
55 #endif |
|
56 #endif // _SLEEP_H |
|
57 |
|
58 |
|
59 // check compiler requirements |
|
60 #if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) |
|
61 #warning __BIG_ENDIAN__ or __LITTLE_ENDIAN__ not found, going to set __LITTLE_ENDIAN__ as default |
|
62 #define __LITTLE_ENDIAN__ 1 |
|
63 #endif |
|
64 |
|
65 /* use byteswap macros from the host system, hopefully optimized ones ;-) |
|
66 * or define our own version, simple, stupid, straight-forward... */ |
|
67 #ifdef HAVE_BYTESWAP_H |
|
68 #include <byteswap.h> |
|
69 #else |
|
70 #define bswap_16(x) (((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8)) |
|
71 #define bswap_32(x) (((x & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8) | \ |
|
72 ((x & 0x0000FF00) << 8) | (((x) & 0x000000FF) << 24) ) |
|
73 #endif /* HAVE_BYTESWAP_H */ |
|
74 |
|
75 /* swap numbers accordingly to architecture automatically */ |
|
76 #ifdef __LITTLE_ENDIAN__ |
|
77 #define ENDIAN_LITTLE_32(x) x |
|
78 #define ENDIAN_BIG_32(x) bswap_32(x) |
|
79 #define ENDIAN_LITTLE_16(x) x |
|
80 #define ENDIAN_BIG_16(x) bswap_16(x) |
|
81 #elif __BIG_ENDIAN__ |
|
82 #define ENDIAN_LITTLE_32(x) bswap_32(x) |
|
83 #define ENDIAN_BIG_32(x) x |
|
84 #define ENDIAN_LITTLE_16(x) bswap_16(x) |
|
85 #define ENDIAN_BIG_16(x) x |
|
86 #endif |
|
87 |
|
88 /* file format defines */ |
|
89 #define OGG_FILE_FORMAT 0x4F676753 |
|
90 #define WAV_FILE_FORMAT 0x52494646 |
|
91 #define WAV_HEADER_SUBCHUNK2ID 0x64617461 |
|
92 |
|
93 |
|
94 #endif /*_OALB_GLOBALS_H*/ |