author | koda |
Sun, 11 Oct 2009 20:40:03 +0000 | |
changeset 2420 | b7390a3040f8 |
parent 2419 | dbaaba09146d |
child 2421 | a4b039ee2eb0 |
permissions | -rw-r--r-- |
2212 | 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 |
|
2257
7eb31efcfb9b
updates licence and fix a memory leak (which was consuming iphone memory)
koda
parents:
2216
diff
changeset
|
6 |
* it under the terms of the GNU Lesser General Public License as published by |
2212 | 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 |
|
2257
7eb31efcfb9b
updates licence and fix a memory leak (which was consuming iphone memory)
koda
parents:
2216
diff
changeset
|
12 |
* GNU Lesser General Public License for more details. |
2212 | 13 |
* |
2257
7eb31efcfb9b
updates licence and fix a memory leak (which was consuming iphone memory)
koda
parents:
2216
diff
changeset
|
14 |
* You should have received a copy of the GNU Lesser General Public License |
2212 | 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 |
||
2213 | 19 |
#ifndef _OALB_GLOBALS_H |
20 |
#define _OALB_GLOBALS_H |
|
2212 | 21 |
|
22 |
#include <stdio.h> |
|
23 |
#include <stdlib.h> |
|
2215 | 24 |
#include <stdint.h> |
2418 | 25 |
#include <stdarg.h> |
26 |
#include <syslog.h> |
|
2259 | 27 |
#include <string.h> |
2418 | 28 |
#include <errno.h> |
2212 | 29 |
|
30 |
#ifndef _WIN32 |
|
31 |
#include <pthread.h> |
|
32 |
#else |
|
33 |
#include <process.h> |
|
34 |
#endif |
|
35 |
||
2213 | 36 |
#include "al.h" |
2418 | 37 |
#include "errlib.h" |
2213 | 38 |
|
2415 | 39 |
|
2418 | 40 |
#ifdef TRACE |
41 |
#ifndef DEBUG |
|
42 |
#define DEBUG |
|
43 |
#endif |
|
44 |
#endif |
|
45 |
||
2415 | 46 |
/** 1.0 02/03/10 - Defines cross-platform sleep, usleep, etc. [Wu Yongwei] **/ |
2212 | 47 |
#ifndef _SLEEP_H |
48 |
#define _SLEEP_H |
|
49 |
#ifdef _WIN32 |
|
50 |
# if defined(_NEED_SLEEP_ONLY) && (defined(_MSC_VER) || defined(__MINGW32__)) |
|
51 |
# include <stdlib.h> |
|
52 |
# define sleep(t) _sleep((t) * 1000) |
|
53 |
# else |
|
2213 | 54 |
# define WIN32_LEAN_AND_MEAN |
2212 | 55 |
# include <windows.h> |
56 |
# define sleep(t) Sleep((t) * 1000) |
|
57 |
# endif |
|
58 |
# ifndef _NEED_SLEEP_ONLY |
|
59 |
# define msleep(t) Sleep(t) |
|
60 |
# define usleep(t) Sleep((t) / 1000) |
|
61 |
# endif |
|
62 |
#else |
|
63 |
# include <unistd.h> |
|
64 |
# ifndef _NEED_SLEEP_ONLY |
|
65 |
# define msleep(t) usleep((t) * 1000) |
|
66 |
# endif |
|
67 |
#endif |
|
68 |
#endif /* _SLEEP_H */ |
|
69 |
||
2420 | 70 |
/* check compiler requirements */ /*FIXME*/ |
2417 | 71 |
#if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) |
2420 | 72 |
#warning __BIG_ENDIAN__ or __LITTLE_ENDIAN__ not found, going to set __LITTLE_ENDIAN__ as default |
73 |
#define __LITTLE_ENDIAN__ 1 |
|
74 |
//#error Do not know the endianess of this architecture |
|
2419 | 75 |
#endif |
2212 | 76 |
|
2417 | 77 |
/* use byteswap macros from the host system, hopefully optimized ones ;-) |
78 |
* or define our own version, simple, stupid, straight-forward... */ |
|
79 |
#ifdef HAVE_BYTESWAP_H |
|
80 |
#include <byteswap.h> |
|
81 |
#else |
|
82 |
#define bswap_16(x) ((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8)) |
|
83 |
#define bswap_32(x) ((((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8) | \ |
|
2420 | 84 |
(((x) & 0x0000FF00) << 8) | (((x) & 0x000000FF) << 24) ) |
2417 | 85 |
#endif /* HAVE_BYTESWAP_H */ |
2212 | 86 |
|
2417 | 87 |
/* swap numbers accordingly to architecture automatically */ |
88 |
#ifdef __LITTLE_ENDIAN__ |
|
89 |
#define ENDIAN_LITTLE_32(x) x |
|
90 |
#define ENDIAN_BIG_32(x) bswap_32(x) |
|
91 |
#define ENDIAN_LITTLE_16(x) x |
|
92 |
#define ENDIAN_BIG_16(x) bswap_16(x) |
|
93 |
#elif __BIG_ENDIAN__ |
|
94 |
#define ENDIAN_LITTLE_32(x) bswap_32(x) |
|
95 |
#define ENDIAN_BIG_32(x) x |
|
96 |
#define ENDIAN_LITTLE_16(x) bswap_16(x) |
|
97 |
#define ENDIAN_BIG_16(x) x |
|
98 |
#endif |
|
2212 | 99 |
|
100 |
||
101 |
#ifdef __CPLUSPLUS |
|
102 |
extern "C" { |
|
103 |
#endif |
|
2415 | 104 |
|
2419 | 105 |
/*data type for WAV header*/ |
2212 | 106 |
#pragma pack(1) |
2415 | 107 |
typedef struct _WAV_header_t { |
108 |
uint32_t ChunkID; |
|
109 |
uint32_t ChunkSize; |
|
110 |
uint32_t Format; |
|
111 |
uint32_t Subchunk1ID; |
|
112 |
uint32_t Subchunk1Size; |
|
113 |
uint16_t AudioFormat; |
|
114 |
uint16_t NumChannels; |
|
115 |
uint32_t SampleRate; |
|
116 |
uint32_t ByteRate; |
|
117 |
uint16_t BlockAlign; |
|
118 |
uint16_t BitsPerSample; |
|
119 |
uint32_t Subchunk2ID; |
|
120 |
uint32_t Subchunk2Size; |
|
121 |
} WAV_header_t; |
|
2212 | 122 |
#pragma pack() |
2415 | 123 |
|
2419 | 124 |
/*data type for passing data between threads*/ |
2216
82e7da49c26a
-Smaxx' patch: checks for initialized openal + disables sound options if openal init fails
koda
parents:
2215
diff
changeset
|
125 |
#pragma pack(1) |
2415 | 126 |
typedef struct _fade_t { |
127 |
uint32_t index; |
|
128 |
uint16_t quantity; |
|
129 |
} fade_t; |
|
2216
82e7da49c26a
-Smaxx' patch: checks for initialized openal + disables sound options if openal init fails
koda
parents:
2215
diff
changeset
|
130 |
#pragma pack() |
2419 | 131 |
|
2415 | 132 |
|
2419 | 133 |
/*file format defines*/ |
2415 | 134 |
#define OGG_FILE_FORMAT 0x4F676753 |
135 |
#define WAV_FILE_FORMAT 0x52494646 |
|
136 |
#define WAV_HEADER_SUBCHUNK2ID 0x64617461 |
|
2419 | 137 |
|
138 |
||
139 |
/*other defines*/ |
|
2418 | 140 |
#define FADE_IN 0 |
2415 | 141 |
#define FADE_OUT 1 |
2419 | 142 |
|
2418 | 143 |
char *prog; |
2415 | 144 |
|
2212 | 145 |
#ifdef __CPLUSPLUS |
146 |
} |
|
147 |
#endif |
|
148 |
||
2213 | 149 |
#endif /*_OALB_GLOBALS_H*/ |