author | koda |
Tue, 14 Jul 2009 20:02:07 +0000 | |
changeset 2261 | 57e99c908e7c |
parent 2260 | 31756e21c436 |
child 2415 | 35d09cbf819a |
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 |
||
2212 | 35 |
#ifndef _SLEEP_H |
36 |
#define _SLEEP_H |
|
37 |
/** 1.0 02/03/10 - Defines cross-platform sleep, usleep, etc. * By Wu Yongwei **/ |
|
38 |
#ifdef _WIN32 |
|
39 |
# if defined(_NEED_SLEEP_ONLY) && (defined(_MSC_VER) || defined(__MINGW32__)) |
|
40 |
# include <stdlib.h> |
|
41 |
# define sleep(t) _sleep((t) * 1000) |
|
42 |
# else |
|
2213 | 43 |
# define WIN32_LEAN_AND_MEAN |
2212 | 44 |
# include <windows.h> |
45 |
# define sleep(t) Sleep((t) * 1000) |
|
46 |
# endif |
|
47 |
# ifndef _NEED_SLEEP_ONLY |
|
48 |
# define msleep(t) Sleep(t) |
|
49 |
# define usleep(t) Sleep((t) / 1000) |
|
50 |
# endif |
|
51 |
#else |
|
52 |
# include <unistd.h> |
|
53 |
# ifndef _NEED_SLEEP_ONLY |
|
54 |
# define msleep(t) usleep((t) * 1000) |
|
55 |
# endif |
|
56 |
#endif |
|
57 |
#endif /* _SLEEP_H */ |
|
58 |
||
59 |
#ifdef HAVE_BYTESWAP_H |
|
60 |
/* use byteswap macros from the host system, hopefully optimized ones ;-) */ |
|
61 |
#include <byteswap.h> |
|
62 |
#else |
|
63 |
/* define our own version, simple, stupid, straight-forward... */ |
|
64 |
||
65 |
#define bswap_16(x) ((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8)) |
|
66 |
||
2260
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
67 |
#define bswap_32(x) ((((x) & 0xFF000000) >> 24) | (((x) & 0x00FF0000) >> 8) | \ |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
68 |
(((x) & 0x0000FF00) << 8) | (((x) & 0x000000FF) << 24) ) |
2212 | 69 |
|
70 |
#endif /* HAVE_BYTESWAP_H */ |
|
71 |
||
72 |
#ifdef __CPLUSPLUS |
|
73 |
extern "C" { |
|
74 |
#endif |
|
2260
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
75 |
|
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
76 |
/*data type for WAV header*/ |
2212 | 77 |
#pragma pack(1) |
2260
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
78 |
typedef struct _WAV_header_t { |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
79 |
uint32_t ChunkID; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
80 |
uint32_t ChunkSize; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
81 |
uint32_t Format; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
82 |
uint32_t Subchunk1ID; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
83 |
uint32_t Subchunk1Size; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
84 |
uint16_t AudioFormat; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
85 |
uint16_t NumChannels; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
86 |
uint32_t SampleRate; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
87 |
uint32_t ByteRate; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
88 |
uint16_t BlockAlign; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
89 |
uint16_t BitsPerSample; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
90 |
uint32_t Subchunk2ID; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
91 |
uint32_t Subchunk2Size; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
92 |
} WAV_header_t; |
2212 | 93 |
#pragma pack() |
2260
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
94 |
|
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
95 |
/*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
|
96 |
#pragma pack(1) |
2260
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
97 |
typedef struct _fade_t { |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
98 |
uint32_t index; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
99 |
uint16_t quantity; |
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
100 |
} fade_t; |
2216
82e7da49c26a
-Smaxx' patch: checks for initialized openal + disables sound options if openal init fails
koda
parents:
2215
diff
changeset
|
101 |
#pragma pack() |
2260
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
102 |
|
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
103 |
/*other defines*/ |
2261 | 104 |
#define FADE_IN AL_TRUE |
105 |
#define FADE_OUT AL_FALSE |
|
2260
31756e21c436
other indentation, binding and miscellaneous fixes to openalbridge
koda
parents:
2259
diff
changeset
|
106 |
|
2212 | 107 |
#ifdef __CPLUSPLUS |
108 |
} |
|
109 |
#endif |
|
110 |
||
2213 | 111 |
#endif /*_OALB_GLOBALS_H*/ |