1 | /* -*- mode: C; tab-width:8; c-basic-offset:8 -*- |
---|
2 | * vi:set ts=8: |
---|
3 | * |
---|
4 | * al_mspool.h |
---|
5 | * |
---|
6 | * Prototypes, macros and definitions related to the management of mspool |
---|
7 | * objects. mspool objects are objects which ease the slab allocation of |
---|
8 | * _alMixSource objects. |
---|
9 | */ |
---|
10 | #ifndef AL_MSPOOL_H_ |
---|
11 | #define AL_MSPOOL_H_ |
---|
12 | |
---|
13 | #include <AL/al.h> |
---|
14 | #include <stdlib.h> |
---|
15 | |
---|
16 | /* |
---|
17 | * MixSource state info. |
---|
18 | */ |
---|
19 | typedef enum _alMixSourceEnum |
---|
20 | { |
---|
21 | ALM_PLAY_ME = (1<<0), |
---|
22 | ALM_DESTROY_ME = (1<<1), |
---|
23 | ALM_STREAMING = (1<<2) |
---|
24 | } _alMixSourceEnum; |
---|
25 | |
---|
26 | /* |
---|
27 | * _alMixSource is the data structure that contains an entry in the mixing |
---|
28 | * queue. Entries have a context id and source id, as well as some processing |
---|
29 | * flags. |
---|
30 | */ |
---|
31 | typedef struct _alMixSource |
---|
32 | { |
---|
33 | ALuint context_id; |
---|
34 | ALuint sid; |
---|
35 | _alMixSourceEnum flags; |
---|
36 | } _alMixSource; |
---|
37 | |
---|
38 | /* |
---|
39 | * The _alMixPool is a type used to facilitate slab allocation of _alMixSource |
---|
40 | * entries. |
---|
41 | */ |
---|
42 | typedef struct _alMixPoolNode |
---|
43 | { |
---|
44 | _alMixSource data; |
---|
45 | ALboolean inuse; |
---|
46 | } _alMixPoolNode; |
---|
47 | |
---|
48 | /* |
---|
49 | * The _alMixPool is a type which contains _alMixPoolNode, in order to |
---|
50 | * facilitate slab allocation. |
---|
51 | */ |
---|
52 | typedef struct _alMixPool |
---|
53 | { |
---|
54 | _alMixPoolNode *pool; |
---|
55 | ALuint size; |
---|
56 | } _alMixPool; |
---|
57 | |
---|
58 | /* |
---|
59 | * Initializes an already allocated _alMixPool object. |
---|
60 | */ |
---|
61 | int _alMixPoolAlloc( _alMixPool *mspool ); |
---|
62 | |
---|
63 | /* |
---|
64 | * Initializes an already allocated _alMixPool object. Returns AL_TRUE, |
---|
65 | * inless initialization failed for some reason, in which case AL_FALSE is |
---|
66 | * returned. |
---|
67 | */ |
---|
68 | ALboolean _alMixPoolResize( _alMixPool *mspool, size_t newsize ); |
---|
69 | |
---|
70 | /* |
---|
71 | * Finalize a _alMixSource, indexed by msindex, using freer_func, |
---|
72 | * from mspool. |
---|
73 | */ |
---|
74 | ALboolean _alMixPoolDealloc( _alMixPool *mspool, int msindex, |
---|
75 | void (*freer_func)(void *)); |
---|
76 | |
---|
77 | /* |
---|
78 | * Return _alMixSource from mspool using simple index, or NULL if msindex is |
---|
79 | * not a valid index. |
---|
80 | */ |
---|
81 | _alMixSource *_alMixPoolIndex( _alMixPool *mspool, int msindex ); |
---|
82 | |
---|
83 | /* |
---|
84 | * Returns first available index in mspool, or -1 if nothing is available. |
---|
85 | */ |
---|
86 | int _alMixPoolFirstFreeIndex( _alMixPool *mspool ); |
---|
87 | |
---|
88 | /* |
---|
89 | * Finalizes each _alMixSource in the _alMixPool object, using freer_func. |
---|
90 | */ |
---|
91 | void _alMixPoolFree( _alMixPool *mspool, void (*freer_func)(void *) ); |
---|
92 | |
---|
93 | #endif /* AL_MSPOOL_H_ */ |
---|