Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/openal-0.0.8/src/alc/alc_context.h @ 53

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

added openal

File size: 6.0 KB
Line 
1/* -*- mode: C; tab-width:8; c-basic-offset:8 -*-
2 * vi:set ts=8:
3 *
4 * alc_context.h
5 *
6 * Prototypes, defines etc for context aquisition and management.
7 */
8#ifndef _ALC_CONTEXT_H_
9#define _ALC_CONTEXT_H_
10
11#include "al_siteconfig.h"
12
13#include <AL/al.h>
14#include <AL/alc.h>
15
16#include "al_types.h"
17
18/*
19 * _ALC_DEF_FREQ is the default internal mixing frequency.
20 */
21#define _ALC_DEF_FREQ        44100
22
23/*
24 * _ALC_DEF_BUFSIZ is the default length of chunks mixed and written to the
25 * audio device.  Must be a power of two.
26 */
27#define _ALC_DEF_BUFSIZ       1024
28
29/*
30 * Canonical stuff
31 */
32#define _ALC_CANON_FMT           AL_FORMAT_MONO16
33#define _ALC_CANON_SPEED         _ALC_DEF_FREQ
34
35#define _ALC_EXTERNAL_FMT        AL_FORMAT_STEREO16
36#define _ALC_EXTERNAL_SPEED      _ALC_DEF_FREQ
37
38/* globally accesible data */
39
40/*
41 * _alcCCId holds the context id of the current context.
42 */
43extern ALuint _alcCCId;
44
45/*
46 * canon_max and canon_min are the max/min values for PCM data in our
47 * canonical format, respectively.
48 */
49extern const int canon_max, canon_min;
50
51
52
53/*
54 * canon_format is the canonical format that we represent data internally as.
55 */
56extern ALenum canon_format;
57
58/*
59 * canon_speed is the sampling rate at which we internally represent data.
60 */
61extern ALuint canon_speed;
62
63/*
64 * Deallocates the data structures allocated in _alcInitContexts.
65 */
66void _alcDestroyAll( void );
67
68/*
69 * Initialize the context named by cid.
70 */
71AL_context *_alcInitContext( ALuint cid );
72
73/*
74 * Returns pointer to the AL_context named by cid, or NULL if cid is not a
75 * valid context name.
76 */
77AL_context *_alcGetContext( ALuint cid );
78
79/*
80 * Returns AL_TRUE if cid names a valid context, AL_FALSE otherwise.
81 */
82ALboolean _alcIsContext( ALuint cid );
83
84/*
85 * Sets context id paramaters according to an attribute list and device.
86 */
87void _alcSetContext( const ALCint *attrlist, ALuint cid, AL_device *dev );
88
89/*
90 * Returns a new id for use as a context name.
91 */
92ALint _alcGetNewContextId( void );
93
94/*
95 * Returns AL_TRUE if the context named by cid is in use, AL_FALSE otherwise.
96 */
97ALboolean _alcInUse( ALuint cid );
98
99/*
100 * Sets the use flag of context with id cid to value.
101 */
102ALboolean _alcSetUse( ALuint cid, ALboolean value );
103
104/*
105 * Returns the preferred read buffer size of the context named by cid,
106 * in bytes.
107 */
108ALuint _alcGetReadBufsiz( ALuint cid );
109
110/*
111 * Returns the preferred write buffer size of the context named by cid,
112 * in bytes.
113 */
114ALuint _alcGetWriteBufsiz( ALuint cid );
115
116/*
117 * Returns the preferred read openal format of the context named by cid.
118 */
119ALenum _alcGetReadFormat( ALuint cid );
120
121/*
122 * Returns the preferred write openal format of the context named by cid.
123 */
124ALenum _alcGetWriteFormat( ALuint cid );
125
126/*
127 * Returns the preferred sampling rate of the read device associated with the
128 * context named by cid.
129 */
130ALuint _alcGetReadSpeed( ALuint cid );
131
132/*
133 * Returns the preferred sampling rate of the write device associated with the
134 * context named by cid.
135 */
136ALuint _alcGetWriteSpeed( ALuint cid );
137
138/*
139 * Returns a pointer to the listener associated with context named by cid, or
140 * NULL if cid does not name a valid context.
141 */
142AL_listener *_alcGetListener( ALuint cid );
143
144/*
145 * Returns AL_TRUE if this context is suspended, AL_FALSE otherwise.
146 * Suspended contexts do not have their sources updated, or mixed.
147 */
148ALboolean _alcIsContextSuspended( ALuint cid );
149
150/*
151 * Returns a pointer to the time_filter_set associated with the context named
152 * by cid, or NULL if cid does not name a context.
153 */
154time_filter_set *_alcGetTimeFilters( ALuint cid );
155
156/*
157 * Locks the mutex associated with the context named by cid, passing fn and ln
158 * to _alLockPrintf for debugging purposes.
159 */
160void FL_alcLockContext( ALuint cid, const char *fn, int ln );
161
162/*
163 * Unlocks the mutex associated with the context named by cid, passing fn and ln
164 * to _alLockPrintf for debugging purposes.
165 */
166void FL_alcUnlockContext( ALuint cid, const char *fn, int ln );
167
168/*
169 * Locks the mutex associated guarding all contexts, passing fn and ln to
170 * _alLockPrintf for debugging purposes.
171 */
172void FL_alcLockAllContexts( const char *fn, int ln );
173
174/*
175 * Unlocks the mutex associated guarding all contexts, passing fn and ln to
176 * _alLockPrintf for debugging purposes.
177 */
178void FL_alcUnlockAllContexts( const char *fn, int ln );
179
180/*
181 * Write bytes_to_write worth of data from data to the device associated with
182 * the context named by cid.
183 */
184void _alcDeviceWrite( ALuint cid, ALvoid *data, ALuint bytes_to_write );
185
186/*
187 * Read bytes_to_read worth of data from the device associated with the
188 * context named by cid.
189 */
190ALsizei _alcDeviceRead( ALuint cid, void *data, ALuint bytes_to_read );
191
192/* default context macros */
193#define _alcDCGetContext()        _alcGetContext(_alcCCId)
194#define _alcDCGetReadBufsiz()     _alcGetReadBufsiz(_alcCCId)
195#define _alcDCGetWriteBufsiz()    _alcGetWriteBufsiz(_alcCCId)
196#define _alcDCGetTimeFilters()    _alcGetTimeFilters(_alcCCId)
197#define _alcDCGetFreqFilters()    _alcGetFreqFilters(_alcCCId)
198#define _alcDCGetListener()       _alcGetListener(_alcCCId)
199#define _alcDCEnableCapture()     _alcEnableCapture(_alcCCId)
200#define _alcDCDisableCapture()    _alcDisableCapture(_alcCCId)
201
202#define _alcDCGetReadSpeed()      _alcGetReadSpeed(_alcCCId)
203#define _alcDCGetReadFormat()     _alcGetReadFormat(_alcCCId)
204#define _alcDCGetWriteSpeed()     _alcGetWriteSpeed(_alcCCId)
205#define _alcDCGetWriteFormat()    _alcGetWriteFormat(_alcCCId)
206#define _alcDCDeviceWrite(d,b)    _alcDeviceWrite(_alcCCId, d, b)
207#define _alcDCDeviceRead(d,b)     _alcDeviceRead(_alcCCId, d, b)
208
209#define _alcDCLockContext()     FL_alcLockContext(_alcCCId, __FILE__, __LINE__)
210#define _alcDCUnlockContext()   FL_alcUnlockContext(_alcCCId,__FILE__, __LINE__)
211#define _alcUnlockContext(c)    FL_alcUnlockContext(c, __FILE__, __LINE__)
212#define _alcLockContext(c)      FL_alcLockContext(c, __FILE__, __LINE__)
213#define _alcUnlockAllContexts() FL_alcUnlockAllContexts(__FILE__, __LINE__)
214#define _alcLockAllContexts()   FL_alcLockAllContexts(__FILE__, __LINE__)
215
216#endif /* _ALC_CONTEXT_H_ */
Note: See TracBrowser for help on using the repository browser.