equal
deleted
inserted
replaced
38 |
38 |
39 ALCcontext *context; |
39 ALCcontext *context; |
40 ALCdevice *device; |
40 ALCdevice *device; |
41 ALuint sources[MAX_SOURCES]; |
41 ALuint sources[MAX_SOURCES]; |
42 |
42 |
43 |
43 char SSound_load (SSound_t* pSound, const char* cFilename); |
44 |
44 void SSound_close (SSound_t* pSound); |
|
45 void SSound_play (SSound_t* pSound, const char bLoop); |
|
46 void SSound_pause (const SSound_t* pSound); |
|
47 void SSound_continue (const SSound_t* pSound); |
|
48 void SSound_stop (SSound_t* pSound); |
|
49 void SSound_volume (const SSound_t* pSound, const float fPercentage); |
45 |
50 |
46 |
51 |
47 /** |
52 /** |
48 * const char oalb_init (const char* programname, const char usehardware) |
53 * const char oalb_init (const char* programname, const char usehardware) |
49 * |
54 * |
55 * RETURN |
60 * RETURN |
56 * 1 success |
61 * 1 success |
57 * 2 error |
62 * 2 error |
58 */ |
63 */ |
59 |
64 |
60 char oalb_init (const char* programname, const char usehardware) { |
65 const char oalb_init (const char* programname, const char usehardware) { |
61 prog = (char *) programname; |
66 prog = (char *) programname; |
62 |
67 |
63 if (oalbReady == AL_TRUE) { |
68 if (oalbReady == AL_TRUE) { |
64 errno = EPERM; |
69 errno = EPERM; |
65 err_ret("(%s) WARN - OpenAL already initialized", prog); |
70 err_ret("(%s) WARN - OpenAL already initialized", prog); |
96 alcMakeContextCurrent(context); |
101 alcMakeContextCurrent(context); |
97 |
102 |
98 if (AlGetError("(%s) WARN - Failed to create a new contex") != AL_TRUE) |
103 if (AlGetError("(%s) WARN - Failed to create a new contex") != AL_TRUE) |
99 return AL_FALSE; |
104 return AL_FALSE; |
100 |
105 |
101 |
|
102 /*set the listener gain, position (on xyz axes), velocity (one value for each axe) and orientation*/ |
106 /*set the listener gain, position (on xyz axes), velocity (one value for each axe) and orientation*/ |
103 alListenerf (AL_GAIN, 1.0f); |
107 alListenerf (AL_GAIN, 1.0f); |
104 alListenerfv(AL_POSITION, NV); |
108 alListenerfv(AL_POSITION, NV); |
105 alListenerfv(AL_VELOCITY, NV); |
109 alListenerfv(AL_VELOCITY, NV); |
106 alListenerfv(AL_ORIENTATION, LO); |
110 alListenerfv(AL_ORIENTATION, LO); |
118 return AL_TRUE; |
122 return AL_TRUE; |
119 } |
123 } |
120 |
124 |
121 |
125 |
122 /** |
126 /** |
123 * void oalb_close(void) |
127 * void oalb_close (void) |
124 * |
128 * |
125 * ARGUMENTS |
129 * ARGUMENTS |
126 * - |
130 * - |
127 * DESCRIPTION |
131 * DESCRIPTION |
128 * |
132 * Stop all sounds, deallocate all memory and close OpenAL |
129 * RETURN |
133 * RETURN |
130 * - |
134 * - |
131 */ |
135 */ |
132 |
136 |
133 void oalb_close(void) { |
137 void oalb_close (void) { |
134 /*Stop all sounds, deallocate all memory and close OpenAL */ |
|
135 int i; |
138 int i; |
136 |
139 |
137 if (oalbReady == 0) { |
140 if (oalbReady == 0) { |
138 errno = EPERM; |
141 errno = EPERM; |
139 err_ret("(%s) WARN - OpenAL not initialized", prog); |
142 err_ret("(%s) WARN - OpenAL not initialized", prog); |
155 oalbReady = 0; |
158 oalbReady = 0; |
156 |
159 |
157 return; |
160 return; |
158 } |
161 } |
159 |
162 |
160 char oalb_ready(void) { |
|
161 return oalbReady; |
|
162 } |
|
163 |
|
164 /** |
163 /** |
165 * const int32_t oalb_loadfile (const char *filename) |
164 * char oalb_ready (void) |
166 * |
165 * |
167 * ARGUMENTS |
166 * ARGUMENTS |
168 * - |
167 * - |
169 * DESCRIPTION |
168 * DESCRIPTION |
170 * |
169 * |
171 * RETURN |
170 * RETURN |
172 * - |
171 * - |
173 */ |
172 */ |
174 |
173 |
175 int32_t oalb_loadfile (const char *filename) { |
174 char oalb_ready (void) { |
|
175 return oalbReady; |
|
176 } |
|
177 |
|
178 /** |
|
179 * const int32_t oalb_loadfile (const char *filename) |
|
180 * |
|
181 * ARGUMENTS |
|
182 * - |
|
183 * DESCRIPTION |
|
184 * |
|
185 * RETURN |
|
186 * - |
|
187 */ |
|
188 |
|
189 const int32_t oalb_loadfile (const char *filename) { |
176 int i; |
190 int i; |
177 |
191 |
178 if (oalbReady == 0) { |
192 if (oalbReady == 0) { |
179 errno = EPERM; |
193 errno = EPERM; |
180 err_ret("(%s) WARN - OpenAL not initialized", prog); |
194 err_ret("(%s) WARN - OpenAL not initialized", prog); |
196 else |
210 else |
197 return -2; |
211 return -2; |
198 |
212 |
199 } |
213 } |
200 |
214 |
201 /* |
|
202 ALboolean openal_toggleloop (uint32_t index){ |
|
203 /*Set or unset looping mode |
|
204 ALint loop; |
|
205 |
|
206 if (oalbReady == AL_FALSE) { |
|
207 errno = EPERM; |
|
208 err_ret("(%s) WARN - OpenAL not initialized", prog); |
|
209 return AL_FALSE; |
|
210 } |
|
211 |
|
212 if (index >= globalsize) { |
|
213 errno = EINVAL; |
|
214 err_ret("(%s) ERROR - Index out of bounds (got %d, max %d)", prog, index, globalindex); |
|
215 return AL_FALSE; |
|
216 } |
|
217 |
|
218 alGetSourcei (Sources[index], AL_LOOPING, &loop); |
|
219 alSourcei (Sources[index], AL_LOOPING, !((uint8_t) loop) & 0x00000001); |
|
220 if (AlGetError("(%s) ERROR - Failed to get or set loop property") != AL_TRUE) |
|
221 return AL_FALSE; |
|
222 |
|
223 alGetError(); /* clear any AL errors beforehand |
|
224 |
|
225 return AL_TRUE; |
|
226 } |
|
227 */ |
|
228 |
215 |
229 void oalb_setvolume (const uint32_t iIndex, const char cPercentage) { |
216 void oalb_setvolume (const uint32_t iIndex, const char cPercentage) { |
230 if (oalbReady == 0) { |
217 if (oalbReady == 0) { |
231 errno = EPERM; |
218 errno = EPERM; |
232 err_ret("(%s) WARN - OpenAL not initialized", prog); |
219 err_ret("(%s) WARN - OpenAL not initialized", prog); |
273 alGetError(); /* clear any AL errors beforehand */ |
260 alGetError(); /* clear any AL errors beforehand */ |
274 |
261 |
275 return; |
262 return; |
276 } |
263 } |
277 |
264 |
278 /* |
265 |
279 ALboolean openal_togglemute () { |
266 void oalb_togglemute (void) { |
280 /*Mute or unmute sound |
267 /*Mute or unmute sound*/ |
281 ALfloat mute; |
268 ALfloat mute; |
282 |
269 |
283 if (oalbReady == AL_FALSE) { |
270 if (oalbReady == AL_FALSE) { |
284 errno = EPERM; |
271 errno = EPERM; |
285 err_ret("(%s) WARN - OpenAL not initialized", prog); |
272 err_ret("(%s) WARN - OpenAL not initialized", prog); |
286 return AL_FALSE; |
273 return; |
287 } |
274 } |
288 |
275 |
289 alGetListenerf (AL_GAIN, &mute); |
276 alGetListenerf (AL_GAIN, &mute); |
290 if (mute > 0) |
277 if (mute > 0) |
291 mute = 0; |
278 mute = 0; |
292 else |
279 else |
293 mute = 1.0; |
280 mute = 1.0; |
294 alListenerf (AL_GAIN, mute); |
281 |
295 if (AlGetError("(%s) ERROR - Failed to set mute property") != AL_TRUE) |
282 alListenerf (AL_GAIN, mute); |
296 return AL_FALSE; |
283 |
297 |
284 if (AlGetError("(%s) ERROR - Failed to set mute property") != AL_TRUE) |
298 alGetError(); /* clear any AL errors beforehand |
285 return; |
299 |
286 |
300 return AL_TRUE; |
287 alGetError(); /* clear any AL errors beforehand */ |
301 } |
288 |
302 |
289 return; |
|
290 } |
|
291 /* |
303 |
292 |
304 ALboolean openal_fade (uint32_t index, uint16_t quantity, ALboolean direction) { |
293 ALboolean openal_fade (uint32_t index, uint16_t quantity, ALboolean direction) { |
305 /*Fade in or out by calling a helper thread |
294 /*Fade in or out by calling a helper thread |
306 #ifndef _WIN32 |
295 #ifndef _WIN32 |
307 pthread_t thread; |
296 pthread_t thread; |