1 | /* -*- mode: C; tab-width:8; c-basic-offset:8 -*- |
---|
2 | * vi:set ts=8: |
---|
3 | * |
---|
4 | * interface_sound.h |
---|
5 | * |
---|
6 | * High level prototypes for sound device aquisition and management. |
---|
7 | * |
---|
8 | */ |
---|
9 | #ifndef AL_BACKENDS_ALC_BACKEND_H_ |
---|
10 | #define AL_BACKENDS_ALC_BACKEND_H_ |
---|
11 | |
---|
12 | #include "al_siteconfig.h" |
---|
13 | |
---|
14 | #include <AL/al.h> |
---|
15 | |
---|
16 | /* |
---|
17 | * An opaque backend structure, only used via pointers from outside. |
---|
18 | */ |
---|
19 | typedef struct ALC_BackendStruct ALC_Backend; |
---|
20 | |
---|
21 | typedef enum |
---|
22 | { |
---|
23 | ALC_OPEN_INPUT_, |
---|
24 | ALC_OPEN_OUTPUT_ |
---|
25 | } ALC_OpenMode; |
---|
26 | |
---|
27 | /* |
---|
28 | * Returns a handle to a backend suitable for reading or writing sound data, or |
---|
29 | * NULL if no such backend is available. This function is used to implement |
---|
30 | * alcOpenDevice. |
---|
31 | */ |
---|
32 | ALC_Backend *alcBackendOpen_ (ALC_OpenMode mode); |
---|
33 | |
---|
34 | /* |
---|
35 | * Closes an (output or input) backend. Returns AL_TRUE if closing was |
---|
36 | * successful, AL_FALSE if the handle was invalid or the backend could not be |
---|
37 | * closed for some reason. This function is used to implement alcCloseDevice. |
---|
38 | */ |
---|
39 | ALboolean alcBackendClose_ (ALC_Backend *backend); |
---|
40 | |
---|
41 | /* |
---|
42 | * Informs a backend that it is about to get paused. This function is used to |
---|
43 | * implement alcMakeContextCurrent(NULL). |
---|
44 | */ |
---|
45 | void alcBackendPause_ (ALC_Backend *backend); |
---|
46 | |
---|
47 | /* |
---|
48 | * Informs a backend that it is about to get resumed. This function is used to |
---|
49 | * implement alcMakeContextCurrent(NON_NULL). |
---|
50 | */ |
---|
51 | void alcBackendResume_ (ALC_Backend *backend); |
---|
52 | |
---|
53 | /* |
---|
54 | * Sets the parameters for a backend. Because we follow a meet-or-exceed |
---|
55 | * policty, *bufsiz, *fmt, and *speed might be different from the parameters |
---|
56 | * initially passed, so the caller should check these after a succesful |
---|
57 | * call. Returns AL_TRUE if setting was successful, AL_FALSE if the parameters |
---|
58 | * could not be matched or exceeded. This function is used to implement |
---|
59 | * alcMakeContextCurrent(NON_NULL). |
---|
60 | */ |
---|
61 | ALboolean alcBackendSetAttributes_ (ALC_Backend *backend, |
---|
62 | ALuint *bufsiz, ALenum *fmt, |
---|
63 | ALuint *speed); |
---|
64 | |
---|
65 | /* |
---|
66 | * Writes a given interleaved array of sound data to an output backend. This |
---|
67 | * function is used to implement (a)sync_mixer_iterate. |
---|
68 | */ |
---|
69 | void alcBackendWrite_ (ALC_Backend *backend, void *data, int size); |
---|
70 | |
---|
71 | /* |
---|
72 | * Captures data from an input backend into the given buffer. This function is |
---|
73 | * used to implement alCaptureGetData_EXT. |
---|
74 | */ |
---|
75 | ALsizei alcBackendRead_ (ALC_Backend *backend, void *data, int size); |
---|
76 | |
---|
77 | /* |
---|
78 | * Returns the normalized volume for the given channel (main/PCM/CD) on an |
---|
79 | * output backend. This function is used to implement alcGetAudioChannel_LOKI. |
---|
80 | */ |
---|
81 | ALfloat alcBackendGetAudioChannel_ (ALC_Backend *backend, ALuint channel); |
---|
82 | |
---|
83 | /* |
---|
84 | * Sets the normalized volume for the given channel (main/PCM/CD) on an output |
---|
85 | * backend. This function is used to implement alcSetAudioChannel_LOKI. |
---|
86 | */ |
---|
87 | void alcBackendSetAudioChannel_ (ALC_Backend *backend, ALuint channel, |
---|
88 | ALfloat volume); |
---|
89 | |
---|
90 | /******************************************************************************/ |
---|
91 | |
---|
92 | /* |
---|
93 | * Various data, the details depend on the backend in question. |
---|
94 | */ |
---|
95 | typedef void ALC_BackendPrivateData; |
---|
96 | |
---|
97 | ALC_BackendPrivateData *alcBackendOpenNative_ (ALC_OpenMode mode); |
---|
98 | void release_native (ALC_BackendPrivateData *privateData); |
---|
99 | void pause_nativedevice (ALC_BackendPrivateData *privateData); |
---|
100 | void resume_nativedevice (ALC_BackendPrivateData *privateData); |
---|
101 | ALboolean alcBackendSetAttributesNative_ (ALC_OpenMode mode, |
---|
102 | ALC_BackendPrivateData *privateData, |
---|
103 | ALuint *bufsiz, ALenum *fmt, |
---|
104 | ALuint *speed); |
---|
105 | void native_blitbuffer (ALC_BackendPrivateData *privateData, void *data, |
---|
106 | int bytes); |
---|
107 | ALsizei capture_nativedevice (ALC_BackendPrivateData *privateData, |
---|
108 | void *capture_buffer, int bufsiz); |
---|
109 | ALfloat get_nativechannel (ALC_BackendPrivateData *privateData, |
---|
110 | ALuint channel); |
---|
111 | int set_nativechannel (ALC_BackendPrivateData *privateData, ALuint channel, |
---|
112 | ALfloat volume); |
---|
113 | |
---|
114 | #ifdef USE_BACKEND_ALSA |
---|
115 | ALC_BackendPrivateData *alcBackendOpenALSA_ (ALC_OpenMode mode); |
---|
116 | void release_alsa (ALC_BackendPrivateData *privateData); |
---|
117 | void pause_alsa (ALC_BackendPrivateData *privateData); |
---|
118 | void resume_alsa (ALC_BackendPrivateData *privateData); |
---|
119 | ALboolean alcBackendSetAttributesALSA_ (ALC_OpenMode mode, |
---|
120 | ALC_BackendPrivateData *privateData, |
---|
121 | ALuint *bufsiz, ALenum *fmt, |
---|
122 | ALuint *speed); |
---|
123 | void alsa_blitbuffer (ALC_BackendPrivateData *privateData, void *data, |
---|
124 | int bytes); |
---|
125 | ALsizei capture_alsa (ALC_BackendPrivateData *privateData, |
---|
126 | void *capture_buffer, int bufsiz); |
---|
127 | ALfloat get_alsachannel (ALC_BackendPrivateData *privateData, ALuint channel); |
---|
128 | int set_alsachannel (ALC_BackendPrivateData *privateData, ALuint channel, |
---|
129 | ALfloat volume); |
---|
130 | #else |
---|
131 | #define alcBackendOpenALSA_(m) NULL |
---|
132 | #define release_alsa(h) |
---|
133 | #define pause_alsa(h) |
---|
134 | #define resume_alsa(h) |
---|
135 | #define alcBackendSetAttributesALSA_(m,h,b,f,s) AL_FALSE |
---|
136 | #define alsa_blitbuffer(h,d,b) |
---|
137 | #define capture_alsa(h,d,b) 0 |
---|
138 | #define get_alsachannel(h,c) 0.0 |
---|
139 | #define set_alsachannel(h,c,v) 0 |
---|
140 | #endif /* USE_BACKEND_ALSA */ |
---|
141 | |
---|
142 | #ifdef USE_BACKEND_ARTS |
---|
143 | ALC_BackendPrivateData *alcBackendOpenARts_ (ALC_OpenMode mode); |
---|
144 | void release_arts (ALC_BackendPrivateData *privateData); |
---|
145 | void pause_arts (ALC_BackendPrivateData *privateData); |
---|
146 | void resume_arts (ALC_BackendPrivateData *privateData); |
---|
147 | ALboolean alcBackendSetAttributesARts_ (ALC_OpenMode mode, |
---|
148 | ALC_BackendPrivateData *privateData, |
---|
149 | ALuint *bufsiz, ALenum *fmt, |
---|
150 | ALuint *speed); |
---|
151 | void arts_blitbuffer (ALC_BackendPrivateData *privateData, void *data, |
---|
152 | int bytes); |
---|
153 | ALsizei capture_arts (ALC_BackendPrivateData *privateData, |
---|
154 | void *capture_buffer, int bufsiz); |
---|
155 | ALfloat get_artschannel (ALC_BackendPrivateData *privateData, ALuint channel); |
---|
156 | int set_artschannel (ALC_BackendPrivateData *privateData, ALuint channel, |
---|
157 | ALfloat volume); |
---|
158 | #else |
---|
159 | #define alcBackendOpenARts_(m) NULL |
---|
160 | #define release_arts(h) |
---|
161 | #define pause_arts(h) |
---|
162 | #define resume_arts(h) |
---|
163 | #define alcBackendSetAttributesARts_(m,h,b,f,s) AL_FALSE |
---|
164 | #define arts_blitbuffer(h,d,b) |
---|
165 | #define capture_arts(h,d,b) 0 |
---|
166 | #define get_artschannel(h,c) 0.0 |
---|
167 | #define set_artschannel(h,c,v) 0 |
---|
168 | #endif /* USE_BACKEND_ARTS */ |
---|
169 | |
---|
170 | #ifdef USE_BACKEND_DMEDIA |
---|
171 | ALC_BackendPrivateData *alcBackendOpenDMedia_ (ALC_OpenMode mode); |
---|
172 | void release_dmedia (ALC_BackendPrivateData *privateData); |
---|
173 | void pause_dmedia (ALC_BackendPrivateData *privateData); |
---|
174 | void resume_dmedia (ALC_BackendPrivateData *privateData); |
---|
175 | ALboolean alcBackendSetAttributesDMedia_ (ALC_OpenMode mode, |
---|
176 | ALC_BackendPrivateData *privateData, |
---|
177 | ALuint *bufsiz, ALenum *fmt, |
---|
178 | ALuint *speed); |
---|
179 | void dmedia_blitbuffer (ALC_BackendPrivateData *privateData, void *data, |
---|
180 | int bytes); |
---|
181 | ALsizei capture_dmedia (ALC_BackendPrivateData *privateData, |
---|
182 | void *capture_buffer, int bufsiz); |
---|
183 | ALfloat get_dmediachannel (ALC_BackendPrivateData *privateData, ALuint channel); |
---|
184 | int set_dmediachannel (ALC_BackendPrivateData *privateData, ALuint channel, |
---|
185 | ALfloat volume); |
---|
186 | #else |
---|
187 | #define alcBackendOpenDMedia_(m) NULL |
---|
188 | #define release_dmedia(h) |
---|
189 | #define pause_dmedia(h) |
---|
190 | #define resume_dmedia(h) |
---|
191 | #define alcBackendSetAttributesDMedia_(m,h,b,f,s) AL_FALSE |
---|
192 | #define dmedia_blitbuffer(h,d,b) |
---|
193 | #define capture_dmedia(h,d,b) 0 |
---|
194 | #define get_dmediachannel(h,c) 0.0 |
---|
195 | #define set_dmediachannel(h,c,v) 0 |
---|
196 | #endif /* USE_BACKEND_DMEDIA */ |
---|
197 | |
---|
198 | #ifdef USE_BACKEND_ESD |
---|
199 | void *alcBackendOpenESD_ (ALC_OpenMode mode); |
---|
200 | void release_esd (ALC_BackendPrivateData *privateData); |
---|
201 | void pause_esd (ALC_BackendPrivateData *privateData); |
---|
202 | void resume_esd (ALC_BackendPrivateData *privateData); |
---|
203 | ALboolean alcBackendSetAttributesESD_ (ALC_OpenMode mode, |
---|
204 | ALC_BackendPrivateData *privateData, |
---|
205 | ALuint *bufsiz, ALenum *fmt, |
---|
206 | ALuint *speed); |
---|
207 | void esd_blitbuffer (ALC_BackendPrivateData *privateData, void *data, |
---|
208 | int bytes); |
---|
209 | ALsizei capture_esd (ALC_BackendPrivateData *privateData, |
---|
210 | void *capture_buffer, int bufsiz); |
---|
211 | ALfloat get_esdchannel (ALC_BackendPrivateData *privateData, ALuint channel); |
---|
212 | int set_esdchannel (ALC_BackendPrivateData *privateData, ALuint channel, |
---|
213 | ALfloat volume); |
---|
214 | #else |
---|
215 | #define alcBackendOpenESD_(m) NULL |
---|
216 | #define pause_esd(h) |
---|
217 | #define release_esd(h) |
---|
218 | #define resume_esd(h) |
---|
219 | #define alcBackendSetAttributesESD_(m,h,b,f,s) AL_FALSE |
---|
220 | #define esd_blitbuffer(h,d,b) |
---|
221 | #define capture_esd(h,d,b) 0 |
---|
222 | #define get_esdchannel(h,c) 0.0 |
---|
223 | #define set_esdchannel(h,c,v) 0 |
---|
224 | #endif /* USE_BACKEND_ESD */ |
---|
225 | |
---|
226 | #ifdef USE_BACKEND_SDL |
---|
227 | ALC_BackendPrivateData *alcBackendOpenSDL_ (ALC_OpenMode mode); |
---|
228 | void release_sdl (ALC_BackendPrivateData *privateData); |
---|
229 | void pause_sdl (ALC_BackendPrivateData *privateData); |
---|
230 | void resume_sdl (ALC_BackendPrivateData *privateData); |
---|
231 | ALboolean alcBackendSetAttributesSDL_ (ALC_OpenMode mode, |
---|
232 | ALC_BackendPrivateData *privateData, |
---|
233 | ALuint *bufsiz, ALenum *fmt, |
---|
234 | ALuint *speed); |
---|
235 | void sdl_blitbuffer (ALC_BackendPrivateData *privateData, void *data, |
---|
236 | int bytes); |
---|
237 | ALsizei capture_sdl (ALC_BackendPrivateData *privateData, |
---|
238 | void *capture_buffer, int bufsiz); |
---|
239 | ALfloat get_sdlchannel (ALC_BackendPrivateData *privateData, ALuint channel); |
---|
240 | int set_sdlchannel (ALC_BackendPrivateData *privateData, ALuint channel, |
---|
241 | ALfloat volume); |
---|
242 | #else |
---|
243 | #define alcBackendOpenSDL_(m) NULL |
---|
244 | #define release_sdl(h) |
---|
245 | #define pause_sdl(h) |
---|
246 | #define resume_sdl(h) |
---|
247 | #define alcBackendSetAttributesSDL_(m,h,b,f,s) AL_FALSE |
---|
248 | #define sdl_blitbuffer(h,d,b) |
---|
249 | #define capture_sdl(h,d,b) 0 |
---|
250 | #define get_sdlchannel(h,c) 0.0 |
---|
251 | #define set_sdlchannel(h,c,v) 0 |
---|
252 | #endif /* USE_BACKEND_SDL */ |
---|
253 | |
---|
254 | #ifdef USE_BACKEND_NULL |
---|
255 | ALC_BackendPrivateData *alcBackendOpenNull_ (ALC_OpenMode mode); |
---|
256 | void release_null (ALC_BackendPrivateData *privateData); |
---|
257 | void pause_null (ALC_BackendPrivateData *privateData); |
---|
258 | void resume_null (ALC_BackendPrivateData *privateData); |
---|
259 | ALboolean alcBackendSetAttributesNull_ (ALC_OpenMode mode, |
---|
260 | ALC_BackendPrivateData *privateData, |
---|
261 | ALuint *bufsiz, ALenum *fmt, |
---|
262 | ALuint *speed); |
---|
263 | void null_blitbuffer (ALC_BackendPrivateData *privateData, void *data, |
---|
264 | int bytes); |
---|
265 | ALsizei capture_null (ALC_BackendPrivateData *privateData, |
---|
266 | void *capture_buffer, int bufsiz); |
---|
267 | ALfloat get_nullchannel (ALC_BackendPrivateData *privateData, ALuint channel); |
---|
268 | int set_nullchannel (ALC_BackendPrivateData *privateData, ALuint channel, |
---|
269 | ALfloat volume); |
---|
270 | #else |
---|
271 | #define alcBackendOpenNull_(m) NULL |
---|
272 | #define release_null(h) |
---|
273 | #define pause_null(h) |
---|
274 | #define resume_null(h) |
---|
275 | #define alcBackendSetAttributesNull_(m,h,b,f,s) AL_FALSE |
---|
276 | #define null_blitbuffer(h,d,b) |
---|
277 | #define capture_null(h,d,b) 0 |
---|
278 | #define get_nullchannel(h,c) 0.0 |
---|
279 | #define set_nullchannel(h,c,v) 0 |
---|
280 | #endif /* USE_BACKEND_NULL */ |
---|
281 | |
---|
282 | #ifdef USE_BACKEND_WAVEOUT |
---|
283 | ALC_BackendPrivateData *alcBackendOpenWAVE_ (ALC_OpenMode mode); |
---|
284 | void release_waveout (ALC_BackendPrivateData *privateData); |
---|
285 | void pause_waveout (ALC_BackendPrivateData *privateData); |
---|
286 | void resume_waveout (ALC_BackendPrivateData *privateData); |
---|
287 | ALboolean alcBackendSetAttributesWAVE_ (ALC_OpenMode mode, |
---|
288 | ALC_BackendPrivateData *privateData, |
---|
289 | ALuint *bufsiz, ALenum *fmt, |
---|
290 | ALuint *speed); |
---|
291 | void waveout_blitbuffer (ALC_BackendPrivateData *privateData, void *data, |
---|
292 | int bytes); |
---|
293 | ALsizei capture_waveout (ALC_BackendPrivateData *privateData, |
---|
294 | void *capture_buffer, int bufsiz); |
---|
295 | ALfloat get_waveoutchannel (ALC_BackendPrivateData *privateData, |
---|
296 | ALuint channel); |
---|
297 | int set_waveoutchannel (ALC_BackendPrivateData *privateData, ALuint channel, |
---|
298 | ALfloat volume); |
---|
299 | #else |
---|
300 | #define alcBackendOpenWAVE_(m) NULL |
---|
301 | #define release_waveout(h) |
---|
302 | #define pause_waveout(h) |
---|
303 | #define resume_waveout(h) |
---|
304 | #define alcBackendSetAttributesWAVE_(m,h,b,f,s) AL_FALSE |
---|
305 | #define waveout_blitbuffer(h,d,b) |
---|
306 | #define capture_waveout(h,d,b) 0 |
---|
307 | #define get_waveoutchannel(h,c) 0.0 |
---|
308 | #define set_waveoutchannel(h,c,v) 0 |
---|
309 | #endif /* USE_BACKEND_WAVEOUT */ |
---|
310 | |
---|
311 | #endif /* AL_BACKENDS_ALC_BACKEND_H_ */ |
---|