author | nemo |
Wed, 21 Apr 2010 21:38:07 +0000 | |
changeset 3363 | bcd6d76db4f7 |
parent 3362 | 8d3b4d19ce27 |
child 3364 | e5403e2bf02c |
permissions | -rw-r--r-- |
3353 | 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 <stdint.h> |
|
25 |
#include <stdarg.h> |
|
26 |
#include <string.h> |
|
27 |
#include <errno.h> |
|
28 |
||
29 |
#ifndef _WIN32 |
|
30 |
#include <pthread.h> |
|
31 |
#include <syslog.h> |
|
32 |
#else |
|
33 |
#include <process.h> |
|
34 |
#define syslog(x,y) fprintf(stderr,y) |
|
35 |
#define LOG_INFO 6 |
|
36 |
#define LOG_ERR 3 |
|
37 |
#endif |
|
38 |
||
39 |
#include "al.h" |
|
40 |
#include "errlib.h" |
|
41 |
||
42 |
||
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3360
diff
changeset
|
43 |
// control debug verbosity |
3353 | 44 |
#ifdef TRACE |
45 |
#ifndef DEBUG |
|
46 |
#define DEBUG |
|
47 |
#endif |
|
48 |
#endif |
|
49 |
||
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3360
diff
changeset
|
50 |
// 1.0 02/03/10 - Defines cross-platform sleep, usleep, etc. [Wu Yongwei] |
3353 | 51 |
#ifndef _SLEEP_H |
52 |
#define _SLEEP_H |
|
53 |
#ifdef _WIN32 |
|
54 |
# if defined(_NEED_SLEEP_ONLY) && (defined(_MSC_VER) || defined(__MINGW32__)) |
|
55 |
# include <stdlib.h> |
|
56 |
# define sleep(t) _sleep((t) * 1000) |
|
57 |
# else |
|
58 |
# define WIN32_LEAN_AND_MEAN |
|
59 |
# include <windows.h> |
|
60 |
# define sleep(t) Sleep((t) * 1000) |
|
61 |
# endif |
|
62 |
# ifndef _NEED_SLEEP_ONLY |
|
63 |
# define msleep(t) Sleep(t) |
|
64 |
# define usleep(t) Sleep((t) / 1000) |
|
65 |
# endif |
|
66 |
#else |
|
67 |
# include <unistd.h> |
|
68 |
# ifndef _NEED_SLEEP_ONLY |
|
69 |
# define msleep(t) usleep((t) * 1000) |
|
70 |
# endif |
|
71 |
#endif |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3360
diff
changeset
|
72 |
#endif // _SLEEP_H |
3353 | 73 |
|
74 |
||
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3360
diff
changeset
|
75 |
// check compiler requirements |
3353 | 76 |
#if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) |
77 |
#warning __BIG_ENDIAN__ or __LITTLE_ENDIAN__ not found, going to set __LITTLE_ENDIAN__ as default |
|
78 |
#define __LITTLE_ENDIAN__ 1 |
|
79 |
#endif |
|
80 |
||
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3360
diff
changeset
|
81 |
/* use byteswap macros from the host system, hopefully optimized ones ;-) |
3353 | 82 |
* or define our own version, simple, stupid, straight-forward... */ |
83 |
#ifdef HAVE_BYTESWAP_H |
|
84 |
#include <byteswap.h> |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3360
diff
changeset
|
85 |
#else |
3353 | 86 |
#define bswap_16(x) ((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8)) |
87 |
#define bswap_32(x) ((((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8) | \ |
|
88 |
(((x) & 0x0000FF00) << 8) | (((x) & 0x000000FF) << 24) ) |
|
89 |
#endif /* HAVE_BYTESWAP_H */ |
|
90 |
||
91 |
/* swap numbers accordingly to architecture automatically */ |
|
92 |
#ifdef __LITTLE_ENDIAN__ |
|
93 |
#define ENDIAN_LITTLE_32(x) x |
|
94 |
#define ENDIAN_BIG_32(x) bswap_32(x) |
|
95 |
#define ENDIAN_LITTLE_16(x) x |
|
96 |
#define ENDIAN_BIG_16(x) bswap_16(x) |
|
97 |
#elif __BIG_ENDIAN__ |
|
98 |
#define ENDIAN_LITTLE_32(x) bswap_32(x) |
|
99 |
#define ENDIAN_BIG_32(x) x |
|
100 |
#define ENDIAN_LITTLE_16(x) bswap_16(x) |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3360
diff
changeset
|
101 |
#define ENDIAN_BIG_16(x) x |
3353 | 102 |
#endif |
103 |
||
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3360
diff
changeset
|
104 |
/*file format defines*/ |
3353 | 105 |
#define OGG_FILE_FORMAT 0x4F676753 |
106 |
#define WAV_FILE_FORMAT 0x52494646 |
|
107 |
#define WAV_HEADER_SUBCHUNK2ID 0x64617461 |
|
3362
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3360
diff
changeset
|
108 |
|
8d3b4d19ce27
in reprocessing openalbridge, a lot of code cleanup and simplification
koda
parents:
3360
diff
changeset
|
109 |
char *prog = "OpenAL subsystem"; |
3353 | 110 |
|
111 |
#endif /*_OALB_GLOBALS_H*/ |