Mercurial > almixer_isolated
annotate Isolated/SoundDecoder.h @ 59:7d508c8cd75a
New implementation backend for SimpleThread using native Windows threading APIs.
Documentation found here:
http://msdn.microsoft.com/en-us/library/kdzttdcb(v=vs.110).aspx
Web searches indicated I should be using _beginthreadex instead of CreateThread for C runtime compatibility.
author | Eric Wing <ewing . public |-at-| gmail . com> |
---|---|
date | Fri, 08 Jun 2012 01:04:51 -0700 |
parents | 208a9ed20087 |
children | be97ae4f30c0 |
rev | line source |
---|---|
38 | 1 |
2 /* | |
3 * This is a wrapper interface that tries to provide a similar | |
4 * front-end interface to SDL_sound. | |
5 */ | |
6 | |
7 #ifndef SOUNDDECODER_H | |
8 #define SOUNDDECODER_H | |
9 | |
10 #ifdef __cplusplus | |
11 extern "C" { | |
12 #endif | |
13 | |
56
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
14 #if defined(_WIN32) |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
15 #if defined(SOUND_DECODER_BUILD_LIBRARY) |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
16 #define SOUND_DECODER_DECLSPEC __declspec(dllexport) |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
17 #else |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
18 #define SOUND_DECODER_DECLSPEC __declspec(dllimport) |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
19 #endif |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
20 #else |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
21 #if defined(SOUND_DECODER_BUILD_LIBRARY) |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
22 #if defined (__GNUC__) && __GNUC__ >= 4 |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
23 #define SOUND_DECODER_DECLSPEC __attribute__((visibility("default"))) |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
24 #else |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
25 #define SOUND_DECODER_DECLSPEC |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
26 #endif |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
27 #else |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
28 #define SOUND_DECODER_DECLSPEC |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
29 #endif |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
30 #endif |
38 | 31 |
56
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
32 #if defined(_WIN32) |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
33 #define SOUND_DECODER_CALL __cdecl |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
34 #else |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
35 #define SOUND_DECODER_CALL |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
36 #endif |
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
37 |
38 | 38 #include <stdint.h> |
39 #include <stddef.h> | |
40 | |
41 #include "al.h" /* OpenAL */ | |
42 | |
43 /* Compatibility defines for SDL */ | |
44 #define AUDIO_U8 0x0008 | |
45 #define AUDIO_S8 0x8008 | |
46 #define AUDIO_U16LSB 0x0010 | |
47 #define AUDIO_S16LSB 0x8010 | |
48 #define AUDIO_U16MSB 0x1010 | |
49 #define AUDIO_S16MSB 0x9010 | |
50 #define AUDIO_U16 AUDIO_U16LSB | |
51 #define AUDIO_S16 AUDIO_S16LSB | |
52 | |
53 #ifdef ANDROID_NDK | |
54 #include <endian.h> | |
55 #if _BYTE_ORDER == _BIG_ENDIAN | |
56 #define __BIG_ENDIAN__ 1 | |
57 #elif _BYTE_ORDER == _LITTLE_ENDIAN | |
58 #define __LITTLE_ENDIAN__ 1 | |
59 #else | |
60 #warning "Android falling back to __LITTLE_ENDIAN__" | |
61 #define __LITTLE_ENDIAN__ 1 | |
62 #endif | |
63 #endif | |
64 | |
65 #if __BIG_ENDIAN__ | |
66 #warning "Using __BIG_ENDIAN__" | |
67 #define AUDIO_U16SYS AUDIO_U16MSB | |
68 #define AUDIO_S16SYS AUDIO_S16MSB | |
69 #elif __LITTLE_ENDIAN__ | |
70 #define AUDIO_U16SYS AUDIO_U16LSB | |
71 #define AUDIO_S16SYS AUDIO_S16LSB | |
72 #else | |
73 #warning "Using __LITTLE_ENDIAN__ as fallback" | |
74 #define AUDIO_U16SYS AUDIO_U16LSB | |
75 #define AUDIO_S16SYS AUDIO_S16LSB | |
76 #endif | |
77 | |
78 struct ALmixer_RWops; | |
79 | |
80 typedef enum | |
81 { | |
82 SOUND_SAMPLEFLAG_NONE = 0, | |
83 SOUND_SAMPLEFLAG_CANSEEK = 1, | |
84 SOUND_SAMPLEFLAG_EOF = 1 << 29, | |
85 SOUND_SAMPLEFLAG_ERROR = 1 << 30, | |
86 SOUND_SAMPLEFLAG_EAGAIN = 1 << 31 | |
87 } SoundDecoder_SampleFlags; | |
88 | |
89 #define Sound_SampleFlags SoundDecoder_SampleFlags; | |
90 | |
91 typedef struct SoundDecoder_AudioInfo | |
92 { | |
93 //uint16_t format; /**< Equivalent of SDL_AudioSpec.format. */ | |
94 ALushort format; /**< Equivalent of SDL_AudioSpec.format. */ | |
95 ALubyte channels; | |
96 // uint8_t channels; | |
97 //uint32_t rate; | |
98 ALuint rate; | |
99 } SoundDecoder_AudioInfo; | |
100 | |
101 //#define Sound_AudioInfo SoundDecoder_AudioInfo; | |
102 typedef struct SoundDecoder_AudioInfo Sound_AudioInfo; | |
103 | |
104 | |
105 | |
106 typedef struct SoundDecoder_DecoderInfo | |
107 { | |
108 const char** extensions; | |
109 const char* description; | |
110 const char* author; | |
111 const char* url; | |
112 } SoundDecoder_DecoderInfo; | |
113 | |
114 //#define Sound_DecoderInfo SoundDecoder_DecoderInfo; | |
115 typedef struct SoundDecoder_DecoderInfo Sound_DecoderInfo; | |
116 | |
117 | |
118 | |
119 typedef struct SoundDecoder_Sample | |
120 { | |
121 void* opaque; | |
122 const SoundDecoder_DecoderInfo* decoder; | |
123 SoundDecoder_AudioInfo desired; | |
124 SoundDecoder_AudioInfo actual; | |
125 void *buffer; | |
126 size_t buffer_size; | |
127 SoundDecoder_SampleFlags flags; | |
128 } SoundDecoder_Sample; | |
129 | |
130 //#define Sound_Sample SoundDecoder_Sample; | |
131 typedef struct SoundDecoder_Sample Sound_Sample; | |
132 | |
133 | |
134 typedef struct SoundDecoder_Version | |
135 { | |
136 int major; | |
137 int minor; | |
138 int patch; | |
139 } SoundDecoder_Version; | |
140 | |
141 //#define Sound_Version SoundDecoder_Version; | |
142 typedef struct SoundDecoder_Version Sound_Version; | |
143 | |
144 | |
145 #define SOUNDDECODER_VER_MAJOR 0 | |
146 #define SOUNDDECODER_VER_MINOR 0 | |
147 #define SOUNDDECODER_VER_PATCH 1 | |
148 | |
149 #define SOUNDDECODER_VERSION(x) \ | |
150 { \ | |
151 (x)->major = SOUNDDECODER_VER_MAJOR; \ | |
152 (x)->minor = SOUNDDECODER_VER_MINOR; \ | |
153 (x)->patch = SOUNDDECODER_VER_PATCH; \ | |
154 } | |
155 | |
156 #define SOUND_VERSION SOUNDDECODER_VERSION | |
157 | |
56
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
158 extern SOUND_DECODER_DECLSPEC void SOUND_DECODER_CALL SoundDecoder_GetLinkedVersion(SoundDecoder_Version *ver); |
38 | 159 #define Sound_GetLinkedVersion SoundDecoder_GetLinkedVersion |
160 | |
56
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
161 extern SOUND_DECODER_DECLSPEC int SOUND_DECODER_CALL SoundDecoder_Init(void); |
38 | 162 #define Sound_Init SoundDecoder_Init |
163 | |
56
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
164 extern SOUND_DECODER_DECLSPEC void SOUND_DECODER_CALL SoundDecoder_Quit(void); |
38 | 165 #define Sound_Quit SoundDecoder_Quit |
166 | |
167 | |
56
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
168 extern SOUND_DECODER_DECLSPEC const SOUND_DECODER_CALL SoundDecoder_DecoderInfo** SoundDecoder_AvailableDecoders(void); |
38 | 169 #define Sound_AvailableDecoders SoundDecoder_AvailableDecoders |
170 | |
171 | |
56
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
172 extern SOUND_DECODER_DECLSPEC const char* SOUND_DECODER_CALL SoundDecoder_GetError(void); |
38 | 173 #define Sound_GetError SoundDecoder_GetError |
174 | |
175 | |
56
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
176 extern SOUND_DECODER_DECLSPEC void SOUND_DECODER_CALL SoundDecoder_ClearError(void); |
38 | 177 #define Sound_ClearError SoundDecoder_ClearError |
178 | |
179 | |
180 | |
56
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
181 extern SOUND_DECODER_DECLSPEC SoundDecoder_Sample* SOUND_DECODER_CALL SoundDecoder_NewSample( |
38 | 182 struct ALmixer_RWops* rw_ops, |
183 const char* ext, | |
184 SoundDecoder_AudioInfo* desired, | |
185 size_t buffer_size); | |
186 #define Sound_NewSample SoundDecoder_NewSample | |
187 | |
56
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
188 extern SOUND_DECODER_DECLSPEC SoundDecoder_Sample* SOUND_DECODER_CALL SoundDecoder_NewSampleFromFile(const char* file_name, |
38 | 189 SoundDecoder_AudioInfo* desired, |
190 size_t bufferSize); | |
191 #define Sound_NewSampleFromFile SoundDecoder_NewSampleFromFile | |
192 | |
193 | |
56
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
194 extern SOUND_DECODER_DECLSPEC void SOUND_DECODER_CALL SoundDecoder_FreeSample(SoundDecoder_Sample* sound_sample); |
38 | 195 #define Sound_FreeSample SoundDecoder_FreeSample |
196 | |
197 | |
56
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
198 extern SOUND_DECODER_DECLSPEC ptrdiff_t SOUND_DECODER_CALL SoundDecoder_GetDuration(SoundDecoder_Sample* sound_sample); |
38 | 199 #define Sound_GetDuration SoundDecoder_GetDuration |
200 | |
56
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
201 extern SOUND_DECODER_DECLSPEC int SOUND_DECODER_CALL SoundDecoder_SetBufferSize(SoundDecoder_Sample* sound_sample, size_t new_buffer_size); |
38 | 202 #define Sound_SetBufferSize SoundDecoder_SetBufferSize |
203 | |
56
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
204 extern SOUND_DECODER_DECLSPEC size_t SOUND_DECODER_CALL SoundDecoder_Decode(SoundDecoder_Sample* sound_sample); |
38 | 205 #define Sound_Decode SoundDecoder_Decode |
206 | |
56
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
207 extern SOUND_DECODER_DECLSPEC size_t SOUND_DECODER_CALL SoundDecoder_DecodeAll(SoundDecoder_Sample* sound_sample); |
38 | 208 #define Sound_DecodeAll SoundDecoder_DecodeAll |
209 | |
56
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
210 extern SOUND_DECODER_DECLSPEC int SOUND_DECODER_CALL SoundDecoder_Rewind(SoundDecoder_Sample* sound_sample); |
38 | 211 #define Sound_Rewind SoundDecoder_Rewind |
212 | |
56
208a9ed20087
Added explicit symbol visibility markers to audio support files in ALmixer for public headers so they can be built as a dynamic library if needed.
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
213 extern SOUND_DECODER_DECLSPEC int SOUND_DECODER_CALL SoundDecoder_Seek(SoundDecoder_Sample* sound_sample, size_t ms); |
38 | 214 #define Sound_Seek SoundDecoder_Seek |
215 | |
216 | |
217 /* Ends C function definitions when using C++ */ | |
218 #ifdef __cplusplus | |
219 } | |
220 #endif | |
221 | |
222 #endif | |
223 |