Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/openal-0.0.8/src/al_source.h @ 37

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

added openal

File size: 7.4 KB
Line 
1/* -*- mode: C; tab-width:8; c-basic-offset:8 -*-
2 * vi:set ts=8:
3 *
4 * al_source.h
5 *
6 * Prototypes, macros and definitions related to the creation and
7 * management of sources.
8 *
9 */
10#ifndef _AL_SOURCE_H_
11#define _AL_SOURCE_H_
12
13#include <stdio.h>
14
15#include "al_types.h"
16
17/*
18 * Non locking version of alIsSource.
19 */
20ALboolean _alIsSource( ALuint sid );
21
22/*
23 * Returns AL_source named by sid from context named by cid.
24 */
25AL_source *_alGetSource( ALuint cid, ALuint sid );
26
27/*
28 * Returns a pointer to the attribute specified by param in the AL_source
29 * object *source, or NULL if the attribute is invalid or has not been set.
30 */
31void *_alGetSourceParam( AL_source *source, ALenum param );
32
33/*
34 * Returns AL_TRUE if param is a valid source attribute and has been set in
35 * source, AL_FALSE otherwise.
36 */
37ALboolean _alSourceIsParamSet( AL_source *source, ALenum param );
38
39/*
40 * Populates *retref with the default value for source attribute param.  If
41 * param is not a valid source attribute, no action is taken.
42 */
43void _alSourceGetParamDefault( ALenum param, ALvoid *retref );
44
45/*
46 * Finalize a source object.
47 */
48void _alDestroySource( ALvoid *src );
49
50/*
51 * Finalize each source object referenced in spool ( see al_spool.h for more
52 * information about source pool objects and their relationship to AL_sources).
53 */
54void _alDestroySources( spool_t *spool );
55
56/*
57 * Populate buffs[0..nc-1][0..len/2-1] with data from buf, with offset into
58 * buf given by the position associated with the source named by sid in the
59 * context named by cid.
60 *
61 * This function delegates to static functions in the case of looping or
62 * callback sounds.
63 */
64void _alSplitSources( ALuint cid, ALuint sid,
65                      ALint nc, ALuint len,
66                      AL_buffer *buf, ALshort **buffs );
67
68/*
69 * Populates the scratch space associated with the source named by sid in the
70 * context named by cid with interleaved data.  The data is interleaved using
71 * alternating channels from buffers[0..nc-1].  Each member of the set
72 * buffers[0..nc-1] is an indepedent channel's worth of data, 0..mixbuflen/2
73 * long bytes long.
74 */
75void _alCollapseSource( ALuint cid, ALuint sid,
76                        ALuint nc, ALuint mixbuflen,
77                        ALshort **buffers );
78
79
80/*
81 * Translates the source (src) position attribute by delta.  Delta is a three
82 * tuple x/y/z.
83 */
84void _alSourceTranslate( AL_source *src, ALfloat *delta );
85
86/*
87 * srcParam functions
88 *
89 * The use of srcParam settings is this: most filter operations break down
90 * into applying a multiplier or delay to the raw PCM data copied in
91 * SplitSources.  Since there operations are cumulative, this can be simplified
92 * by simply collecting the coefficients of the operations and applying them
93 * all at one.  So instead of actually performing a gain or delay operation on
94 * the PCM data, the filter can change the srcParam setting, which is applied
95 * in _alSourceParamApply.
96 *
97 */
98
99/*
100 * Resets the srcParam settings gain and delay.  Does not affect srcParam
101 * settings associated with sound position or the temporary scratch space.
102 */
103void _alSourceParamReset( AL_source *src );
104
105/*
106 * Applies the srcParam settings of src to buffers[0..nc-1][0..(len/2)-1].
107 */
108void _alSourceParamApply( AL_source *src,
109                          ALuint nc, ALuint len, ALshort **buffers );
110
111/*
112 * Returns the number of buffers queued in the source, not including the
113 * current one ( if any ).
114 */
115ALint _alSourceGetPendingBids( AL_source *src );
116
117/*
118 * Returns the next buffer in a queue, or NULL if no next buffer exists.
119 * Assumes locked source.
120 *
121 */
122AL_buffer *_alSourceGetNextBuffer( AL_source *src );
123
124/*
125 * Returns the total number of buffers queued for the source,
126 * without regard to the read or write pointer.
127 */
128ALint _alSourceQueuedBuffers( AL_source *src );
129
130/*
131 * Copies the interleaved data from src[0..(src_size/2)-1] to
132 * dstret[0..dest_channels-1], splitting it into seperate channels.
133 * src_channels describes the period of the channel repetition in src,
134 * dest_channels describes the number of independant buffers in dstref.
135 * src_size is the size of src in bytes, and offset is the offset into each
136 * seperate channel in dstref where the copying begins.
137 */
138void _alMonoifyOffset( ALshort **dstref, ALuint offset,
139                       ALvoid *src, ALuint src_size,
140                       ALuint dest_channels, ALuint src_channels );
141
142/*
143 * This function is sort of the complement of _alMonoifyOffset.  Data is
144 * copied from srcs[0..nc-1][offset/2..(offset + size)/2-1] into an
145 * interleaved array dst.
146 */
147void _alChannelifyOffset( ALshort *dst, ALuint offset,
148                          ALshort **srcs, ALuint size, ALuint nc );
149
150
151/*
152 * Usually, the top-level mixing function _alMixSources handles updating each
153 * source's sound position ( a pointer into its associate buffer's raw PCM
154 * data. )  Some attributes, like pitch, demand a more sophisticated approach
155 * that can only be done by the filter which handles this attribute.
156 *
157 * _alSourceShouldIncrement returns AL_TRUE if the top-level mixing function
158 * should update this sort of state information, and AL_FALSE if it should
159 * leave it to another portion of the library.
160 */
161ALboolean _alSourceShouldIncrement( AL_source *src );
162
163/*
164 * Increments the source's (src) offset into its current buffer's PCM data.
165 */
166void _alSourceIncrement( AL_source *src, ALuint bytes );
167
168/*
169 * Returns the byte length of the amount of data left before this source/samp
170 * pair will either run out of data or be required to wrap.  This returns the
171 * byte length of an interleaved array, with periodic repetition equal to the
172 * number of channels in the canonical format.
173 */
174ALint _alSourceBytesLeft( AL_source *src, AL_buffer *samp );
175
176/*
177 * Returns the byte length of the amount of data left before this source/samp
178 * pair will either run out of data or be required to wrap.  This returns the
179 * byte length of a simple array, with 1 channel's worth of data.
180 */
181ALint _alSourceBytesLeftByChannel( AL_source *src, AL_buffer *samp );
182
183/*
184 * Returns AL_TRUE if the source (src) has its queue set to AL_TRUE,
185 * AL_FALSE otherwise.
186 */
187ALboolean _alSourceIsQueue( AL_source * src );
188
189/*
190 * Returns AL_TRUE if the source (src) has its AL_LOOPING attribute set to
191 * AL_TRUE, AL_FALSE otherwise.
192 */
193ALboolean _alSourceIsLooping( AL_source *src );
194
195/*
196 * Locks the mutex guarding source sid in context cid, and passes fn and ln
197 * to _alLockPrintf for debugging purposes.
198 */
199ALboolean FL_alLockSource( const char *fn, int ln, ALuint cid, ALuint sid );
200
201/*
202 * Unlocks the mutex guarding source sid in context cid, and passes fn and ln
203 * to _alLockPrintf for debugging purposes.
204 */
205ALboolean FL_alUnlockSource( const char *fn, int ln, ALuint cid, ALuint sid );
206
207/* macros */
208#define _alDCGetSource(i)              _alGetSource(_alcCCId, i)
209#define _alChannelify(d,srcs,size,nc)  _alChannelifyOffset(d, 0, srcs, size, nc)
210#define _alMonoify(d, s, size, dc, sc) _alMonoifyOffset(d, 0, s, size, dc, sc)
211#define _alLockSource(cid, sid)        FL_alLockSource(__FILE__, __LINE__, cid, sid)
212#define _alUnlockSource(cid, sid)      FL_alUnlockSource(__FILE__, __LINE__, cid, sid)
213#define _alDCLockSource(sid)           FL_alLockSource(__FILE__, __LINE__, _alcCCId, sid)
214#define _alDCUnlockSource(sid)         FL_alUnlockSource(__FILE__, __LINE__, _alcCCId, sid)
215
216#ifdef PARANOID_LOCKING
217#define SOURCELOCK()   _alcDCLockContext()
218#define SOURCEUNLOCK() _alcDCUnlockContext()
219#else
220#define SOURCELOCK()
221#define SOURCEUNLOCK()
222#endif
223
224/*
225 * AL_FIRST_SOURCE_ID is the first integer value at which source names are
226 * created.
227 */
228#define AL_FIRST_SOURCE_ID  0x4000
229
230#endif /* _AL_SOURCE_H_ */
Note: See TracBrowser for help on using the repository browser.