author | koda |
Tue, 07 Jul 2009 15:24:43 +0000 | |
changeset 2239 | d7b5c65f7544 |
parent 2216 | 82e7da49c26a |
child 2257 | 7eb31efcfb9b |
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 |
|
6 |
* it under the terms of the GNU 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 General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU 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 |
||
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> |
2212 | 25 |
|
26 |
#ifndef _WIN32 |
|
27 |
#include <pthread.h> |
|
28 |
#else |
|
29 |
#include <process.h> |
|
30 |
#endif |
|
31 |
||
2213 | 32 |
#include "al.h" |
33 |
||
2212 | 34 |
#ifndef _SLEEP_H |
35 |
#define _SLEEP_H |
|
36 |
/** 1.0 02/03/10 - Defines cross-platform sleep, usleep, etc. * By Wu Yongwei **/ |
|
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 |
|
2213 | 42 |
# define WIN32_LEAN_AND_MEAN |
2212 | 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 |
#ifdef HAVE_BYTESWAP_H |
|
59 |
/* use byteswap macros from the host system, hopefully optimized ones ;-) */ |
|
60 |
#include <byteswap.h> |
|
61 |
#else |
|
62 |
/* define our own version, simple, stupid, straight-forward... */ |
|
63 |
||
64 |
#define bswap_16(x) ((((x) & 0xFF00) >> 8) | (((x) & 0x00FF) << 8)) |
|
65 |
||
66 |
#define bswap_32(x) ((((x) & 0xFF000000) >> 24) | \ |
|
67 |
(((x) & 0x00FF0000) >> 8) | \ |
|
68 |
(((x) & 0x0000FF00) << 8) | \ |
|
69 |
(((x) & 0x000000FF) << 24) ) |
|
70 |
||
71 |
#endif /* HAVE_BYTESWAP_H */ |
|
72 |
||
73 |
#ifdef __CPLUSPLUS |
|
74 |
extern "C" { |
|
75 |
#endif |
|
76 |
||
77 |
/*data type for WAV header*/ |
|
78 |
#pragma pack(1) |
|
79 |
typedef struct _WAV_header_t { |
|
2215 | 80 |
uint32_t ChunkID; |
81 |
uint32_t ChunkSize; |
|
82 |
uint32_t Format; |
|
83 |
uint32_t Subchunk1ID; |
|
84 |
uint32_t Subchunk1Size; |
|
85 |
uint16_t AudioFormat; |
|
86 |
uint16_t NumChannels; |
|
87 |
uint32_t SampleRate; |
|
88 |
uint32_t ByteRate; |
|
89 |
uint16_t BlockAlign; |
|
90 |
uint16_t BitsPerSample; |
|
91 |
uint32_t Subchunk2ID; |
|
92 |
uint32_t Subchunk2Size; |
|
2212 | 93 |
} WAV_header_t; |
94 |
#pragma pack() |
|
95 |
||
96 |
/*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
|
97 |
#pragma pack(1) |
2212 | 98 |
typedef struct _fade_t { |
2216
82e7da49c26a
-Smaxx' patch: checks for initialized openal + disables sound options if openal init fails
koda
parents:
2215
diff
changeset
|
99 |
uint32_t index; |
82e7da49c26a
-Smaxx' patch: checks for initialized openal + disables sound options if openal init fails
koda
parents:
2215
diff
changeset
|
100 |
uint16_t quantity; |
2212 | 101 |
} fade_t; |
2216
82e7da49c26a
-Smaxx' patch: checks for initialized openal + disables sound options if openal init fails
koda
parents:
2215
diff
changeset
|
102 |
#pragma pack() |
2212 | 103 |
|
104 |
/*other defines*/ |
|
105 |
#define FADE_IN 11 |
|
106 |
#define FADE_OUT 12 |
|
107 |
||
108 |
#ifdef __CPLUSPLUS |
|
109 |
} |
|
110 |
#endif |
|
111 |
||
2213 | 112 |
#endif /*_OALB_GLOBALS_H*/ |