Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/openal-0.0.8/src/al_types.h @ 17

Last change on this file since 17 was 17, checked in by landauf, 16 years ago

added openal

File size: 7.8 KB
Line 
1/* -*- mode: C; tab-width:8; c-basic-offset:8 -*-
2 * vi:set ts=8:
3 *
4 * al_types.h
5 *
6 * internal type definitions
7 *
8 * Naming convention: If the spec describes an attribute AL_FOO_BAR, the
9 * corresponding struct has a field foo_bar. Furthermore, the fields are ordered
10 * in the same way as they are described in the spec.
11 */
12
13#ifndef _LAL_TYPES_H_
14#define _LAL_TYPES_H_
15
16#include <AL/al.h>
17#include <AL/alc.h>
18
19#include "al_mutexlib.h"
20
21#include <stddef.h>
22#include <sys/types.h>
23
24#define _ALC_MAX_CHANNELS    6
25#define _ALC_MAX_FILTERS     9
26
27#define _ALF_MAX_NAME        15
28#define _AL_MAX_DISTANCE     (60.0f)
29#define SIZEOFVECTOR         (sizeof(ALfloat) * 3)
30
31typedef struct _ALmatrix {
32        ALfloat **data;
33        ALint rows;
34        ALint cols;
35} ALmatrix;
36
37typedef enum _DeviceEnum {
38        ALCD_NONE                = 0,
39        ALCD_WRITE               = (1<<0),
40        ALCD_READ                = (1<<1)
41} DeviceEnum;
42
43typedef enum _EnableEnum {
44        ALE_NONE                 = 0
45} EnableEnum;
46
47typedef enum _SrcEnum {
48        ALS_NONE           = 0,
49        ALS_REVERB         = (1<<0),
50        ALS_NEEDPITCH      = (1<<1)  /* don't increment */
51} SrcEnum;
52
53/* flags that are set in the source on a buffer by buffer basis */
54typedef enum _QueueEnum {
55        ALQ_NONE           = 0,
56        ALQ_CALLBACKBUFFER = (1<<0) /* don't increment */
57} QueueEnum;
58
59typedef enum _Bufenum {
60        ALB_NONE           = 0,
61        ALB_STREAMING      = (1<<1),
62        ALB_STREAMING_WRAP = (1<<2),
63        ALB_CALLBACK       = (1<<3),
64        ALB_PENDING_DELETE = (1<<4)
65} Bufenum;
66
67typedef struct {
68        ALboolean isset;
69        ALfloat data;
70} AL_floatparam;
71
72typedef struct {
73        ALboolean isset;
74        ALfloat data[3];
75} AL_float3vparam;
76
77typedef struct {
78        ALboolean isset;
79        ALfloat data[6];
80} AL_float6vparam;
81
82typedef struct {
83        ALboolean isset;
84        ALint data;
85} AL_intparam;
86
87typedef struct {
88        ALboolean isset;
89        ALboolean data;
90} AL_boolparam;
91
92typedef struct {
93        ALboolean isset;
94        ALuint data;
95} AL_uintparam;
96
97typedef struct {
98        ALboolean isset;
99        ALshort data;
100} AL_shortparam;
101
102
103typedef void (*AL_funcPtr)(void);
104
105typedef struct _AL_extension {
106        const ALubyte *name;
107        AL_funcPtr addr;
108} AL_extension;
109
110/* internal use destruction callbacks */
111typedef void (*DestroyCallback_LOKI)(ALuint id);
112
113/* scratch space to avoid unneeded reallocs */
114typedef struct {
115        void *data[_ALC_MAX_CHANNELS];
116        ALuint len;
117} _alDecodeScratch;
118
119typedef struct _AL_bufsourcelist {
120        ALuint *sids;
121        ALuint size;
122        ALuint items;
123} AL_bufsourcelist;
124
125/*
126 *  Our buffer
127 */
128typedef struct {
129        /*
130         * The following three fields are the "official" part of the buffer
131         * state, the rest are implementation details. Note that the bits per
132         * sample and the number of channels can be calculated from the format.
133         */
134        ALuint frequency;
135        ALuint size;
136        ALshort format;
137
138        ALuint bid;         /* unique identifier */
139
140        void *orig_buffers[_ALC_MAX_CHANNELS];    /* original buffer: unadulturated */
141        ALuint num_buffers; /* number of populated channels in orig_buffers */
142
143        Bufenum flags;
144        /* int refcount; */
145
146        /* our refcount */
147        AL_bufsourcelist queue_list;
148        AL_bufsourcelist current_list;
149
150        ALuint streampos; /* position for streaming sounds */
151        ALuint appendpos; /* position for append operation */
152
153        /* callback for on-the-fly decoding */
154        int (*callback)(ALuint, ALuint, ALshort *, ALenum, ALint, ALint);
155
156        DestroyCallback_LOKI destroy_buffer_callback; /* callback for when
157                                                       * buffer is destroyed */
158        DestroyCallback_LOKI destroy_source_callback; /* callback for when
159                                                       * source is destroyed */
160} AL_buffer;
161
162/*
163 * AL_sourcestate is used to store buffer specific parameters.
164 */
165typedef struct _AL_sourcestate {
166        QueueEnum flags;
167} AL_sourcestate;
168
169typedef struct _AL_source {
170        /*
171         * The following sixteen fields are the "official" part of the source
172         * state, the rest are implementation details. Note that the AL_BUFFER,
173         * AL_BUFFERS_QUEUED, and AL_BUFFERS_PROCESSED attributes are implicitly
174         * in bid_queue. Furthermore, AL_SEC_OFFSET, AL_SAMPLE_OFFSET, and
175         * AL_BYTE_OFFSET can probably calculated from one of the fields below,
176         * but this has not been implemented yet.
177         */
178        AL_float3vparam position;
179        AL_float3vparam velocity;
180        AL_floatparam gain;
181        AL_boolparam relative;
182        AL_intparam source_type; /* TODO: Currently unused. */
183        AL_boolparam looping;
184        AL_floatparam min_gain;
185        AL_floatparam max_gain;
186        AL_floatparam reference_distance;
187        AL_floatparam rolloff_factor;
188        AL_floatparam max_distance;
189        AL_floatparam pitch;
190        AL_float3vparam direction;
191        AL_floatparam cone_inner_angle;
192        AL_floatparam cone_outer_angle;
193        AL_floatparam cone_outer_gain;
194
195        struct {
196                AL_sourcestate *queuestate;
197                ALuint *queue;
198
199                int size;
200                int read_index;  /* what al_mixer reads   */
201                int write_index; /* what Queue{i,f} reads */
202        } bid_queue;  /* buffer queue */
203
204        /* Our state */
205        ALenum state;
206
207        struct {
208                unsigned long soundpos; /* position into sound */
209
210                /*
211                 * It really makes more sense for split source to
212                 * maintain soundpos, so set these.  If this works
213                 * out move everything over to use them.
214                 */
215                ssize_t new_soundpos;
216                ssize_t new_readindex;
217
218                void *outbuf;           /* buffer where output data is stored */
219                ALuint delay[_ALC_MAX_CHANNELS];
220                ALfloat gain[_ALC_MAX_CHANNELS];
221        } srcParams; /* values refreshed each iteration through SplitSources */
222
223        SrcEnum flags;
224
225        /* kludges follow */
226        void *reverb_buf[_ALC_MAX_CHANNELS]; /* reverb data */
227        long reverbpos;
228        long reverblen;
229
230        ALfloat reverb_scale;
231        ALint   reverb_delay;
232
233        /* true mixing rate of the source */
234        ALfloat mixrate;
235       
236        ALuint sid; /* our identifier */
237} AL_source;
238
239typedef struct _AL_listener {
240        /*
241         * The following four fields are the "official" part of the listener
242         * state. We are lucky and need nothing else here... :-)
243         */
244        ALfloat position[3];
245        ALfloat velocity[3];
246        ALfloat gain;
247        ALfloat orientation[6];
248} AL_listener;
249
250typedef struct _AL_capture {
251        ALuint cpid;
252        ALuint state;
253
254        AL_intparam bid;
255} AL_capture;
256
257/* pool structures */
258typedef struct
259{
260        AL_source data;
261        ALboolean inuse;
262} spool_node;
263
264typedef struct
265{
266        spool_node *pool;
267        ALuint size;
268        ALuint *map;        /* { sid, index } pair.  map[index] = sid */
269        MutexID *smutexen;  /* array of source locks */
270} spool_t;
271
272typedef void time_filter (ALuint c, AL_source *src, AL_buffer *samp,
273                   ALshort **buffers, ALuint nc, ALuint len);
274
275/* types */
276typedef struct _time_filter_set {
277        char name[ _ALF_MAX_NAME + 1 ];
278        time_filter *filter;
279} time_filter_set;
280
281struct _AL_context;
282
283typedef struct ALCdevice_struct {
284        struct _AL_context *cc;
285
286        void *handle;        /*
287                              * pointer to something that is meaningful
288                              * to the OS's sound stuff
289                              */
290
291        /* device settings, not internal format */
292        ALenum format;
293        ALuint speed;
294        ALuint bufsiz;
295
296        DeviceEnum flags;
297        ALCchar *specifier;
298} AL_device;
299
300typedef struct _AL_context {
301        /*
302         * The following four fields are the "official" part of the context
303         * state, the rest are implementation details. Note that there are
304         * currently no enable/disable flags in the spec, so there is no field
305         * for these.
306         */
307        ALfloat doppler_factor;
308        ALfloat doppler_velocity; /* deprecated */
309        ALfloat speed_of_sound;
310        ALenum distance_model;
311
312        AL_listener listener;
313
314        spool_t source_pool;
315
316        ALboolean _inuse;
317
318        AL_device *write_device;
319        AL_device *read_device;
320
321        /* distance of speaker from
322         * origin  [x,y,z].  Ranges from 0.0 (origin) to
323         * 1.0 * scaling_factor
324         *
325         * 0 -> left
326         * 1 -> right
327         * 2 -> left satellite
328         * 3 -> right satellite
329         */
330        struct {
331                ALfloat pos[3];
332        } _speaker_pos[_ALC_MAX_CHANNELS];
333
334
335        ALint alErrorIndex;
336
337        time_filter_set time_filters[_ALC_MAX_FILTERS];
338
339        ALboolean should_sync; /* is mojo updated synchronous? */
340        ALboolean issuspended; /* is the context suspended? */
341
342        /* structure for restoring system mixer settings */
343        struct {
344                ALfloat main;
345                ALfloat pcm;
346        } restore;
347
348        ALfloat (*distance_func)( ALfloat dist, ALfloat rolloff,
349                                  ALfloat ref, ALfloat max );
350
351        ALint *Flags;
352        ALint NumFlags;
353} AL_context;
354
355typedef struct _alMixEntry {
356        ALvoid *data;
357        ALint bytes;
358} alMixEntry;
359
360#endif /* _LAL_TYPES_H */
Note: See TracBrowser for help on using the repository browser.