1 | /* -*- mode: C; tab-width:8; c-basic-offset:8 -*- |
---|
2 | * vi:set ts=8: |
---|
3 | * |
---|
4 | * al_spool.h |
---|
5 | * |
---|
6 | * Prototypes, macros and definitions related to the management of spool |
---|
7 | * objects. spool objects are objects which ease the slab allocation of |
---|
8 | * AL_source objects. |
---|
9 | * |
---|
10 | */ |
---|
11 | #ifndef _AL_SPOOL_H_ |
---|
12 | #define _AL_SPOOL_H_ |
---|
13 | |
---|
14 | #include "al_types.h" |
---|
15 | |
---|
16 | #include <sys/types.h> |
---|
17 | |
---|
18 | /* |
---|
19 | * source pool stuff |
---|
20 | * |
---|
21 | * overcomplicated method of pooling sources to avoid memory |
---|
22 | * fragmentation. |
---|
23 | * |
---|
24 | */ |
---|
25 | |
---|
26 | /* |
---|
27 | * Creates, initializes and returns source pool object. |
---|
28 | */ |
---|
29 | void spool_init( spool_t *spool ); |
---|
30 | |
---|
31 | /* |
---|
32 | * Allocates a source pool node and returns and index that can be used in |
---|
33 | * other spool_ calls. |
---|
34 | */ |
---|
35 | int spool_alloc( spool_t *spool ); |
---|
36 | |
---|
37 | /* |
---|
38 | * Deallocates all source pool nodes in a source pool object. |
---|
39 | */ |
---|
40 | void spool_free( spool_t *spool, void (*freer_func)(void *) ); |
---|
41 | |
---|
42 | /* |
---|
43 | * Returns the index of first unused source pool node. |
---|
44 | */ |
---|
45 | int spool_first_free_index( spool_t *spool ); |
---|
46 | |
---|
47 | /* |
---|
48 | * retrieve the source pool node associated with sindex from the source pool |
---|
49 | * object spool. |
---|
50 | */ |
---|
51 | AL_source *spool_index( spool_t *spool, ALuint sindex ); |
---|
52 | |
---|
53 | /* |
---|
54 | * Converts an AL_source name (sid) to the source pool node index suitable |
---|
55 | * for passing to spool_index. |
---|
56 | */ |
---|
57 | int spool_sid_to_index( spool_t *spool, ALuint sid ); |
---|
58 | |
---|
59 | /* |
---|
60 | * Returns next suitable AL_source name (id) suitable for using in |
---|
61 | * al calls ( alSourcei( sid, ... ), etc ) |
---|
62 | */ |
---|
63 | ALuint spool_next_id( void ); |
---|
64 | |
---|
65 | /* |
---|
66 | * Finalizes a source pool node, keyed off of sid, in spool, using freer_func. |
---|
67 | */ |
---|
68 | ALboolean spool_dealloc( spool_t *spool, ALuint sid, |
---|
69 | void (*freer_func)(void *) ); |
---|
70 | |
---|
71 | /* |
---|
72 | * Increases the size of source pool object spool to accomodate at least size |
---|
73 | * source pool nodes. |
---|
74 | */ |
---|
75 | ALboolean spool_resize( spool_t *spool, size_t size ); |
---|
76 | |
---|
77 | #endif /* AL_SPOOL_H_ */ |
---|