Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

added openal

File size: 5.2 KB
Line 
1/* -*- mode: C; tab-width:8; c-basic-offset:8 -*-
2 * vi:set ts=8:
3 *
4 * al_main.h
5 *
6 * Miscellanous prototypes, macros and definitions
7 */
8#ifndef _AL_MAIN_H_
9#define _AL_MAIN_H_
10
11#include "al_siteconfig.h"
12
13#include <AL/al.h>
14
15#include "alc/alc_context.h"
16
17/*
18 * _alLockPrintf is used for debugging purposes.  If DEBUG_LOCK is defined,
19 * calls to _alLockPrintf generate a print to stderr.  If not, these calls are
20 * optimized away.
21 */
22#ifndef DEBUG_LOCK
23#define _alLockPrintf(x, f, l)
24#else
25int _alLockPrintf( const char *str, const char *fn, int line );
26#endif /* DEBUG_LOCK */
27
28/*
29 * evaluates to the depth of the passed audioconvert format, in bits.
30 */
31#define _al_ACformatbits(fmt) (fmt & 0x00FF)
32
33/*
34 * These macros are make calls to the associated regular-library str calls,
35 * but cast their arguments to const char * before doing so.  This is to aid
36 * the manipulate of const ALubyte * strings.
37 */
38#define ustrcmp(s1, s2)     strcmp((const char *) s1, (const char *) s2)
39#define ustrncmp(s1, s2, n) strncmp((const char *) s1, \
40                                    (const char *) s2, \
41                                    n)
42#define ustrncpy(s1, s2, n) strncpy((char *) s1, \
43                                    (const char *) s2, \
44                                    n)
45
46/*
47 * Like memcpy, but copies to dst + offset instead of to dst.
48 */
49#define offset_memcpy(d,o,s,l) memcpy(((char *)d) + o, s, l)
50
51/*
52 * Like memcpy, but copies from src + offset instead of from src.
53 */
54#define memcpy_offset(d,s,o,l) memcpy(d, (char *) s + o, l)
55
56/*
57 * If DEBUG_STUB is defined, _alStub prints out a warning message.  If not, no
58 * action is taken.
59 *
60 */
61#ifdef DEBUG_STUB
62void _alStub( const char *str );
63#else
64#define _alStub( s )
65#endif /* DEBUG_STUB */
66
67/*
68 * Does misc. initialization for the library.
69 */
70ALboolean _alInit( void );
71
72/*
73 * Deallocates the data structures created by _alInit.
74 */
75void _alExit( void );
76
77/*
78 * Returns the openal format that has the number of channels channels and the
79 * bit depth bits.
80 */
81ALenum _al_AL2FMT( ALuint channels, ALuint bits );
82
83/*
84 * Returns the openal format equivilant to the audioconvert format acformat,
85 * with the number of channels specified by channels.
86 */
87ALenum _al_AC2ALFMT( ALuint acformat, ALuint channels );
88
89/*
90 * Returns the equivilant (sort of) audioconvert format specified by alfmt.
91 * audioconvert formats do not have channel information, so this should be
92 * combined with _alGetChannelsFromFormat.
93 */
94ALushort _al_AL2ACFMT( ALenum alfmt );
95
96/*
97 * evaluates to the number of channels in an openal format.
98 */
99ALubyte  _alGetChannelsFromFormat(ALenum alformat);
100
101/*
102 * Returns the number of bits per sample for the given format.
103 */
104ALbyte _alGetBitsFromFormat( ALenum format );
105
106/*
107 * Returns the openal format that is identical to format, but with sufficient
108 * channel width to accomedate new_channel_num channels.
109 */
110ALenum _al_formatscale( ALenum format, ALuint new_channel_num );
111
112/*
113 * Returns the number of byte necessary to contain samples worth of data, if
114 * the data undergoes a conversion from ffreq to tfreq in the sampling-rate
115 * and from ffmt to tfmt in terms of format.
116 */
117ALuint _al_PCMRatioify( ALuint ffreq, ALuint tfreq,
118                        ALenum ffmt, ALenum tfmt,
119                        ALuint samples );
120
121/*
122 *  Returns AL_TRUE if format is an openal format specifying raw pcm data,
123 *  AL_FALSE otherwise.
124 */
125ALboolean _al_RAWFORMAT( ALenum format );
126
127/*
128 * Multiplies each ALshort in bpt (len bytes long) by sa, clamped above
129 * by 32767 and below by -32768.  Only appropriate for 0.0 <= sa <= 1.0.
130 */
131void _alFloatMul( ALshort *bpt, ALfloat sa, ALuint len );
132
133/*
134 * Starts the mixer thread.
135 */
136void _alStartMixerThread( void );
137
138/*
139 * Waits for the mixer thread to die.  This call does not kill the mixer
140 * thread, it just hangs around poking the body.
141 */
142void _alWaitForMixerThreadToDie( void );
143
144/*
145 * Copies srcs[0..nc-1][0..(len/2)-1] to
146 * dsts[0..nc-1][offset/2..((offset + len)/2)-1].
147 */
148void _alBuffersAppend( void **dsts, void **srcs, int len, int offset, int nc );
149
150/*
151 * slurp file named by fname to into *buffer, mallocing memory.
152 */
153int _alSlurp( const char *fname, void **buffer );
154
155/*
156 * sleep for n microseconds
157 */
158void _alMicroSleep( unsigned int n );
159
160/*
161 * Convert degree argument to radians
162 */
163ALfloat _alDegreeToRadian( ALfloat degree );
164
165/*
166 * Functions for verifying values fall between min and max,
167 * inclusive.
168 */
169
170/*
171 * Returns AL_TRUE if val is between min and max, inclusive.
172 */
173ALboolean _alCheckRangef( ALfloat val, ALfloat min, ALfloat max );
174
175/*
176 * Returns AL_TRUE if val is either AL_TRUE or AL_FALSE.
177 */
178ALboolean _alCheckRangeb( ALboolean val );
179
180/*
181 * Returns true if fv1 == { 0.0f, 0.0f, 0.0f }
182 */
183ALboolean _alIsZeroVector( const ALfloat *fv1 );
184
185/*
186 * the buffers that sources are split into in SplitSources and
187 * Collapsed from in CollapseSources.  Filters work on these
188 * intermediate buffers, each of which contains one mono channel of
189 * the source data.
190 *
191 * f_buffers contain PCM data
192 */
193
194extern _alDecodeScratch f_buffers;
195
196/*
197 * Returns smallest power of two large that meets or exceeds num.
198 */
199ALuint _alSmallestPowerOfTwo( ALuint num );
200
201/*
202 * Returns AL_TRUE if v is a finite, non NaN value, AL_FALSE otherwise.
203 */
204ALboolean _alIsFinite( ALfloat v );
205
206
207/*
208 * Returns smallest power of two that meets or exceeds num.
209 */
210ALuint _alSpot( ALuint num );
211
212#endif
Note: See TracBrowser for help on using the repository browser.