author | koda |
Sun, 11 Oct 2009 16:23:59 +0000 | |
changeset 2417 | f7ed1ea25050 |
parent 2415 | 35d09cbf819a |
child 2418 | 538a777f90c4 |
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> |
2259 | 25 |
#include <string.h> |
2212 | 26 |
|
27 |
#ifndef _WIN32 |
|
28 |
#include <pthread.h> |
|
29 |
#else |
|
30 |
#include <process.h> |
|
31 |
#endif |
|
32 |
||
2213 | 33 |
#include "al.h" |
34 |
||
2415 | 35 |
|
36 |
/** 1.0 02/03/10 - Defines cross-platform sleep, usleep, etc. [Wu Yongwei] **/ |
|
2212 | 37 |
#ifndef _SLEEP_H |
38 |
#define _SLEEP_H |
|
39 |
#ifdef _WIN32 |
|
40 |
# if defined(_NEED_SLEEP_ONLY) && (defined(_MSC_VER) || defined(__MINGW32__)) |
|
41 |
# include <stdlib.h> |
|
42 |
# define sleep(t) _sleep((t) * 1000) |
|
43 |
# else |
|
2213 | 44 |
# define WIN32_LEAN_AND_MEAN |
2212 | 45 |
# include <windows.h> |
46 |
# define sleep(t) Sleep((t) * 1000) |
|
47 |
# endif |
|
48 |
# ifndef _NEED_SLEEP_ONLY |
|
49 |
# define msleep(t) Sleep(t) |
|
50 |
# define usleep(t) Sleep((t) / 1000) |
|
51 |
# endif |
|
52 |
#else |
|
53 |
# include <unistd.h> |
|
54 |
# ifndef _NEED_SLEEP_ONLY |
|
55 |
# define msleep(t) usleep((t) * 1000) |
|
56 |
# endif |
|
57 |
#endif |
|
58 |
#endif /* _SLEEP_H */ |
|
59 |
||
2415 | 60 |
|
2417 | 61 |
/* check compiler requirements */ |
62 |
#if !defined(__BIG_ENDIAN__) && !defined(__LITTLE_ENDIAN__) |
|
63 |
#error Do not know the endianess of this architecture |
|
64 |
#endif |
|
2212 | 65 |
|
2417 | 66 |
/* use byteswap macros from the host system, hopefully optimized ones ;-) |
67 |
* or define our own version, simple, stupid, straight-forward... */ |
|
68 |
#ifdef HAVE_BYTESWAP_H |
|
69 |
#include <byteswap.h> |
|
70 |
#else |
|
71 |
#define bswap_16(x) ((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8)) |
|
72 |
#define bswap_32(x) ((((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8) | \ |
|
73 |
(((x) & 0x0000FF00) << 8) | (((x) & 0x000000FF) << 24) ) |
|
74 |
#endif /* HAVE_BYTESWAP_H */ |
|
2212 | 75 |
|
2417 | 76 |
/* swap numbers accordingly to architecture automatically */ |
77 |
#ifdef __LITTLE_ENDIAN__ |
|
78 |
#define ENDIAN_LITTLE_32(x) x |
|
79 |
#define ENDIAN_BIG_32(x) bswap_32(x) |
|
80 |
#define ENDIAN_LITTLE_16(x) x |
|
81 |
#define ENDIAN_BIG_16(x) bswap_16(x) |
|
82 |
#elif __BIG_ENDIAN__ |
|
83 |
#define ENDIAN_LITTLE_32(x) bswap_32(x) |
|
84 |
#define ENDIAN_BIG_32(x) x |
|
85 |
#define ENDIAN_LITTLE_16(x) bswap_16(x) |
|
86 |
#define ENDIAN_BIG_16(x) x |
|
87 |
#endif |
|
2212 | 88 |
|
89 |
||
90 |
#ifdef __CPLUSPLUS |
|
91 |
extern "C" { |
|
92 |
#endif |
|
2415 | 93 |
|
94 |
/*data type for WAV header*/ |
|
2212 | 95 |
#pragma pack(1) |
2415 | 96 |
typedef struct _WAV_header_t { |
97 |
uint32_t ChunkID; |
|
98 |
uint32_t ChunkSize; |
|
99 |
uint32_t Format; |
|
100 |
uint32_t Subchunk1ID; |
|
101 |
uint32_t Subchunk1Size; |
|
102 |
uint16_t AudioFormat; |
|
103 |
uint16_t NumChannels; |
|
104 |
uint32_t SampleRate; |
|
105 |
uint32_t ByteRate; |
|
106 |
uint16_t BlockAlign; |
|
107 |
uint16_t BitsPerSample; |
|
108 |
uint32_t Subchunk2ID; |
|
109 |
uint32_t Subchunk2Size; |
|
110 |
} WAV_header_t; |
|
2212 | 111 |
#pragma pack() |
2415 | 112 |
|
113 |
/*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
|
114 |
#pragma pack(1) |
2415 | 115 |
typedef struct _fade_t { |
116 |
uint32_t index; |
|
117 |
uint16_t quantity; |
|
118 |
} fade_t; |
|
2216
82e7da49c26a
-Smaxx' patch: checks for initialized openal + disables sound options if openal init fails
koda
parents:
2215
diff
changeset
|
119 |
#pragma pack() |
2415 | 120 |
|
121 |
||
122 |
/*file format defines*/ |
|
123 |
#define OGG_FILE_FORMAT 0x4F676753 |
|
124 |
#define WAV_FILE_FORMAT 0x52494646 |
|
125 |
#define WAV_HEADER_SUBCHUNK2ID 0x64617461 |
|
126 |
||
127 |
||
128 |
/*other defines*/ |
|
129 |
#define FADE_IN 0 |
|
130 |
#define FADE_OUT 1 |
|
131 |
||
2212 | 132 |
#ifdef __CPLUSPLUS |
133 |
} |
|
134 |
#endif |
|
135 |
||
2213 | 136 |
#endif /*_OALB_GLOBALS_H*/ |