Mercurial > fife-parpg
comparison ext/openal-soft/OpenAL32/alState.c @ 0:4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sun, 29 Jun 2008 18:44:17 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a0efb7baf70 |
---|---|
1 /** | |
2 * OpenAL cross platform audio library | |
3 * Copyright (C) 1999-2000 by authors. | |
4 * This library is free software; you can redistribute it and/or | |
5 * modify it under the terms of the GNU Library General Public | |
6 * License as published by the Free Software Foundation; either | |
7 * version 2 of the License, or (at your option) any later version. | |
8 * | |
9 * This library is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 * Library General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU Library General Public | |
15 * License along with this library; if not, write to the | |
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
17 * Boston, MA 02111-1307, USA. | |
18 * Or go to http://www.gnu.org/copyleft/lgpl.html | |
19 */ | |
20 | |
21 #include "config.h" | |
22 | |
23 #include <stdlib.h> | |
24 #include "alMain.h" | |
25 #include "AL/alc.h" | |
26 #include "alError.h" | |
27 #include "alState.h" | |
28 | |
29 static const ALchar alVendor[] = "OpenAL Community"; | |
30 static const ALchar alVersion[] = "1.1"; | |
31 static const ALchar alRenderer[] = "OpenAL Soft"; | |
32 | |
33 // Error Messages | |
34 static const ALchar alNoError[] = "No Error"; | |
35 static const ALchar alErrInvalidName[] = "Invalid Name"; | |
36 static const ALchar alErrInvalidEnum[] = "Invalid Enum"; | |
37 static const ALchar alErrInvalidValue[] = "Invalid Value"; | |
38 static const ALchar alErrInvalidOp[] = "Invalid Operation"; | |
39 static const ALchar alErrOutOfMemory[] = "Out of Memory"; | |
40 | |
41 ALAPI ALvoid ALAPIENTRY alEnable(ALenum capability) | |
42 { | |
43 ALCcontext *Context; | |
44 | |
45 Context=alcGetCurrentContext(); | |
46 if (Context) | |
47 { | |
48 SuspendContext(Context); | |
49 | |
50 switch (capability) | |
51 { | |
52 default: | |
53 alSetError(AL_INVALID_ENUM); | |
54 break; | |
55 } | |
56 | |
57 ProcessContext(Context); | |
58 } | |
59 else | |
60 { | |
61 // Invalid Context | |
62 alSetError(AL_INVALID_OPERATION); | |
63 } | |
64 } | |
65 | |
66 ALAPI ALvoid ALAPIENTRY alDisable(ALenum capability) | |
67 { | |
68 ALCcontext *Context; | |
69 | |
70 Context=alcGetCurrentContext(); | |
71 if (Context) | |
72 { | |
73 SuspendContext(Context); | |
74 | |
75 switch (capability) | |
76 { | |
77 default: | |
78 alSetError(AL_INVALID_ENUM); | |
79 break; | |
80 } | |
81 | |
82 ProcessContext(Context); | |
83 } | |
84 else | |
85 { | |
86 // Invalid Context | |
87 alSetError(AL_INVALID_OPERATION); | |
88 } | |
89 } | |
90 | |
91 ALAPI ALboolean ALAPIENTRY alIsEnabled(ALenum capability) | |
92 { | |
93 ALCcontext *Context; | |
94 ALboolean value=AL_FALSE; | |
95 | |
96 Context=alcGetCurrentContext(); | |
97 if (Context) | |
98 { | |
99 SuspendContext(Context); | |
100 | |
101 switch (capability) | |
102 { | |
103 default: | |
104 alSetError(AL_INVALID_ENUM); | |
105 break; | |
106 } | |
107 | |
108 ProcessContext(Context); | |
109 } | |
110 else | |
111 { | |
112 // Invalid Context | |
113 alSetError(AL_INVALID_OPERATION); | |
114 } | |
115 | |
116 return value; | |
117 } | |
118 | |
119 ALAPI ALboolean ALAPIENTRY alGetBoolean(ALenum pname) | |
120 { | |
121 ALCcontext *Context; | |
122 ALboolean value=AL_FALSE; | |
123 | |
124 Context=alcGetCurrentContext(); | |
125 if (Context) | |
126 { | |
127 SuspendContext(Context); | |
128 | |
129 switch (pname) | |
130 { | |
131 case AL_DOPPLER_FACTOR: | |
132 if (Context->DopplerFactor != 0.0f) | |
133 value = AL_TRUE; | |
134 break; | |
135 | |
136 case AL_DOPPLER_VELOCITY: | |
137 if (Context->DopplerVelocity != 0.0f) | |
138 value = AL_TRUE; | |
139 break; | |
140 | |
141 case AL_DISTANCE_MODEL: | |
142 if (Context->DistanceModel == AL_INVERSE_DISTANCE_CLAMPED) | |
143 value = AL_TRUE; | |
144 break; | |
145 | |
146 case AL_SPEED_OF_SOUND: | |
147 if (Context->flSpeedOfSound != 0.0f) | |
148 value = AL_TRUE; | |
149 break; | |
150 | |
151 default: | |
152 alSetError(AL_INVALID_ENUM); | |
153 break; | |
154 } | |
155 | |
156 ProcessContext(Context); | |
157 } | |
158 else | |
159 { | |
160 // Invalid Context | |
161 alSetError(AL_INVALID_OPERATION); | |
162 } | |
163 | |
164 return value; | |
165 } | |
166 | |
167 ALAPI ALdouble ALAPIENTRY alGetDouble(ALenum pname) | |
168 { | |
169 ALCcontext *Context; | |
170 ALdouble value = 0.0; | |
171 | |
172 Context=alcGetCurrentContext(); | |
173 if (Context) | |
174 { | |
175 SuspendContext(Context); | |
176 | |
177 switch (pname) | |
178 { | |
179 case AL_DOPPLER_FACTOR: | |
180 value = (double)Context->DopplerFactor; | |
181 break; | |
182 | |
183 case AL_DOPPLER_VELOCITY: | |
184 value = (double)Context->DopplerVelocity; | |
185 break; | |
186 | |
187 case AL_DISTANCE_MODEL: | |
188 value = (double)Context->DistanceModel; | |
189 break; | |
190 | |
191 case AL_SPEED_OF_SOUND: | |
192 value = (double)Context->flSpeedOfSound; | |
193 break; | |
194 | |
195 default: | |
196 alSetError(AL_INVALID_ENUM); | |
197 break; | |
198 } | |
199 | |
200 ProcessContext(Context); | |
201 } | |
202 else | |
203 { | |
204 // Invalid Context | |
205 alSetError(AL_INVALID_OPERATION); | |
206 } | |
207 | |
208 return value; | |
209 } | |
210 | |
211 ALAPI ALfloat ALAPIENTRY alGetFloat(ALenum pname) | |
212 { | |
213 ALCcontext *Context; | |
214 ALfloat value = 0.0f; | |
215 | |
216 Context=alcGetCurrentContext(); | |
217 if (Context) | |
218 { | |
219 SuspendContext(Context); | |
220 | |
221 switch (pname) | |
222 { | |
223 case AL_DOPPLER_FACTOR: | |
224 value = Context->DopplerFactor; | |
225 break; | |
226 | |
227 case AL_DOPPLER_VELOCITY: | |
228 value = Context->DopplerVelocity; | |
229 break; | |
230 | |
231 case AL_DISTANCE_MODEL: | |
232 value = (float)Context->DistanceModel; | |
233 break; | |
234 | |
235 case AL_SPEED_OF_SOUND: | |
236 value = Context->flSpeedOfSound; | |
237 break; | |
238 | |
239 default: | |
240 alSetError(AL_INVALID_ENUM); | |
241 break; | |
242 } | |
243 | |
244 ProcessContext(Context); | |
245 } | |
246 else | |
247 { | |
248 // Invalid Context | |
249 alSetError(AL_INVALID_OPERATION); | |
250 } | |
251 | |
252 return value; | |
253 } | |
254 | |
255 ALAPI ALint ALAPIENTRY alGetInteger(ALenum pname) | |
256 { | |
257 ALCcontext *Context; | |
258 ALint value = 0; | |
259 | |
260 Context=alcGetCurrentContext(); | |
261 if (Context) | |
262 { | |
263 SuspendContext(Context); | |
264 | |
265 switch (pname) | |
266 { | |
267 case AL_DOPPLER_FACTOR: | |
268 value = (ALint)Context->DopplerFactor; | |
269 break; | |
270 | |
271 case AL_DOPPLER_VELOCITY: | |
272 value = (ALint)Context->DopplerVelocity; | |
273 break; | |
274 | |
275 case AL_DISTANCE_MODEL: | |
276 value = (ALint)Context->DistanceModel; | |
277 break; | |
278 | |
279 case AL_SPEED_OF_SOUND: | |
280 value = (ALint)Context->flSpeedOfSound; | |
281 break; | |
282 | |
283 default: | |
284 alSetError(AL_INVALID_ENUM); | |
285 break; | |
286 } | |
287 | |
288 ProcessContext(Context); | |
289 } | |
290 else | |
291 { | |
292 // Invalid Context | |
293 alSetError(AL_INVALID_OPERATION); | |
294 } | |
295 | |
296 return value; | |
297 } | |
298 | |
299 ALAPI ALvoid ALAPIENTRY alGetBooleanv(ALenum pname,ALboolean *data) | |
300 { | |
301 ALCcontext *Context; | |
302 | |
303 Context=alcGetCurrentContext(); | |
304 if (Context) | |
305 { | |
306 SuspendContext(Context); | |
307 | |
308 if (data) | |
309 { | |
310 switch (pname) | |
311 { | |
312 case AL_DOPPLER_FACTOR: | |
313 *data = (ALboolean)((Context->DopplerFactor != 0.0f) ? AL_TRUE : AL_FALSE); | |
314 break; | |
315 | |
316 case AL_DOPPLER_VELOCITY: | |
317 *data = (ALboolean)((Context->DopplerVelocity != 0.0f) ? AL_TRUE : AL_FALSE); | |
318 break; | |
319 | |
320 case AL_DISTANCE_MODEL: | |
321 *data = (ALboolean)((Context->DistanceModel == AL_INVERSE_DISTANCE_CLAMPED) ? AL_TRUE : AL_FALSE); | |
322 break; | |
323 | |
324 case AL_SPEED_OF_SOUND: | |
325 *data = (ALboolean)((Context->flSpeedOfSound != 0.0f) ? AL_TRUE : AL_FALSE); | |
326 break; | |
327 | |
328 default: | |
329 alSetError(AL_INVALID_ENUM); | |
330 break; | |
331 } | |
332 } | |
333 else | |
334 { | |
335 // data is a NULL pointer | |
336 alSetError(AL_INVALID_VALUE); | |
337 } | |
338 | |
339 ProcessContext(Context); | |
340 } | |
341 else | |
342 { | |
343 // Invalid Context | |
344 alSetError(AL_INVALID_OPERATION); | |
345 } | |
346 | |
347 return; | |
348 } | |
349 | |
350 ALAPI ALvoid ALAPIENTRY alGetDoublev(ALenum pname,ALdouble *data) | |
351 { | |
352 ALCcontext *Context; | |
353 | |
354 Context=alcGetCurrentContext(); | |
355 if (Context) | |
356 { | |
357 SuspendContext(Context); | |
358 | |
359 if (data) | |
360 { | |
361 switch (pname) | |
362 { | |
363 case AL_DOPPLER_FACTOR: | |
364 *data = (double)Context->DopplerFactor; | |
365 break; | |
366 | |
367 case AL_DOPPLER_VELOCITY: | |
368 *data = (double)Context->DopplerVelocity; | |
369 break; | |
370 | |
371 case AL_DISTANCE_MODEL: | |
372 *data = (double)Context->DistanceModel; | |
373 break; | |
374 | |
375 case AL_SPEED_OF_SOUND: | |
376 *data = (double)Context->flSpeedOfSound; | |
377 break; | |
378 | |
379 default: | |
380 alSetError(AL_INVALID_ENUM); | |
381 break; | |
382 } | |
383 } | |
384 else | |
385 { | |
386 // data is a NULL pointer | |
387 alSetError(AL_INVALID_VALUE); | |
388 } | |
389 | |
390 ProcessContext(Context); | |
391 } | |
392 else | |
393 { | |
394 // Invalid Context | |
395 alSetError(AL_INVALID_OPERATION); | |
396 } | |
397 | |
398 return; | |
399 } | |
400 | |
401 ALAPI ALvoid ALAPIENTRY alGetFloatv(ALenum pname,ALfloat *data) | |
402 { | |
403 ALCcontext *Context; | |
404 | |
405 Context=alcGetCurrentContext(); | |
406 if (Context) | |
407 { | |
408 SuspendContext(Context); | |
409 | |
410 if (data) | |
411 { | |
412 switch (pname) | |
413 { | |
414 case AL_DOPPLER_FACTOR: | |
415 *data = Context->DopplerFactor; | |
416 break; | |
417 | |
418 case AL_DOPPLER_VELOCITY: | |
419 *data = Context->DopplerVelocity; | |
420 break; | |
421 | |
422 case AL_DISTANCE_MODEL: | |
423 *data = (float)Context->DistanceModel; | |
424 break; | |
425 | |
426 case AL_SPEED_OF_SOUND: | |
427 *data = Context->flSpeedOfSound; | |
428 break; | |
429 | |
430 default: | |
431 alSetError(AL_INVALID_ENUM); | |
432 break; | |
433 } | |
434 } | |
435 else | |
436 { | |
437 // data is a NULL pointer | |
438 alSetError(AL_INVALID_VALUE); | |
439 } | |
440 | |
441 ProcessContext(Context); | |
442 } | |
443 else | |
444 { | |
445 // Invalid Context | |
446 alSetError(AL_INVALID_OPERATION); | |
447 } | |
448 | |
449 return; | |
450 } | |
451 | |
452 ALAPI ALvoid ALAPIENTRY alGetIntegerv(ALenum pname,ALint *data) | |
453 { | |
454 ALCcontext *Context; | |
455 | |
456 Context=alcGetCurrentContext(); | |
457 if (Context) | |
458 { | |
459 SuspendContext(Context); | |
460 | |
461 if (data) | |
462 { | |
463 switch (pname) | |
464 { | |
465 case AL_DOPPLER_FACTOR: | |
466 *data = (ALint)Context->DopplerFactor; | |
467 break; | |
468 | |
469 case AL_DOPPLER_VELOCITY: | |
470 *data = (ALint)Context->DopplerVelocity; | |
471 break; | |
472 | |
473 case AL_DISTANCE_MODEL: | |
474 *data = (ALint)Context->DistanceModel; | |
475 break; | |
476 | |
477 case AL_SPEED_OF_SOUND: | |
478 *data = (ALint)Context->flSpeedOfSound; | |
479 break; | |
480 | |
481 default: | |
482 alSetError(AL_INVALID_ENUM); | |
483 break; | |
484 } | |
485 } | |
486 else | |
487 { | |
488 // data is a NULL pointer | |
489 alSetError(AL_INVALID_VALUE); | |
490 } | |
491 | |
492 ProcessContext(Context); | |
493 } | |
494 else | |
495 { | |
496 // Invalid Context | |
497 alSetError(AL_INVALID_OPERATION); | |
498 } | |
499 | |
500 return; | |
501 } | |
502 | |
503 ALAPI const ALchar* ALAPIENTRY alGetString(ALenum pname) | |
504 { | |
505 const ALchar *value; | |
506 ALCcontext *pContext; | |
507 | |
508 pContext = alcGetCurrentContext(); | |
509 if(!pContext) | |
510 { | |
511 alSetError(AL_INVALID_OPERATION); | |
512 return NULL; | |
513 } | |
514 | |
515 SuspendContext(pContext); | |
516 | |
517 switch(pname) | |
518 { | |
519 case AL_VENDOR: | |
520 value=alVendor; | |
521 break; | |
522 | |
523 case AL_VERSION: | |
524 value=alVersion; | |
525 break; | |
526 | |
527 case AL_RENDERER: | |
528 value=alRenderer; | |
529 break; | |
530 | |
531 case AL_EXTENSIONS: | |
532 value=pContext->ExtensionList;//alExtensions; | |
533 break; | |
534 | |
535 case AL_NO_ERROR: | |
536 value=alNoError; | |
537 break; | |
538 | |
539 case AL_INVALID_NAME: | |
540 value=alErrInvalidName; | |
541 break; | |
542 | |
543 case AL_INVALID_ENUM: | |
544 value=alErrInvalidEnum; | |
545 break; | |
546 | |
547 case AL_INVALID_VALUE: | |
548 value=alErrInvalidValue; | |
549 break; | |
550 | |
551 case AL_INVALID_OPERATION: | |
552 value=alErrInvalidOp; | |
553 break; | |
554 | |
555 case AL_OUT_OF_MEMORY: | |
556 value=alErrOutOfMemory; | |
557 break; | |
558 | |
559 default: | |
560 value=NULL; | |
561 alSetError(AL_INVALID_ENUM); | |
562 break; | |
563 } | |
564 | |
565 ProcessContext(pContext); | |
566 | |
567 return value; | |
568 } | |
569 | |
570 ALAPI ALvoid ALAPIENTRY alDopplerFactor(ALfloat value) | |
571 { | |
572 ALCcontext *Context; | |
573 | |
574 Context=alcGetCurrentContext(); | |
575 if (Context) | |
576 { | |
577 SuspendContext(Context); | |
578 | |
579 if (value>=0.0f) | |
580 Context->DopplerFactor = value; | |
581 else | |
582 alSetError(AL_INVALID_VALUE); | |
583 | |
584 ProcessContext(Context); | |
585 } | |
586 else | |
587 { | |
588 // Invalid Context | |
589 alSetError(AL_INVALID_OPERATION); | |
590 } | |
591 | |
592 return; | |
593 } | |
594 | |
595 ALAPI ALvoid ALAPIENTRY alDopplerVelocity(ALfloat value) | |
596 { | |
597 ALCcontext *Context; | |
598 | |
599 Context=alcGetCurrentContext(); | |
600 if (Context) | |
601 { | |
602 SuspendContext(Context); | |
603 | |
604 if (value>0.0f) | |
605 Context->DopplerVelocity=value; | |
606 else | |
607 alSetError(AL_INVALID_VALUE); | |
608 | |
609 ProcessContext(Context); | |
610 } | |
611 else | |
612 { | |
613 // Invalid Context | |
614 alSetError(AL_INVALID_OPERATION); | |
615 } | |
616 | |
617 return; | |
618 } | |
619 | |
620 ALAPI ALvoid ALAPIENTRY alSpeedOfSound(ALfloat flSpeedOfSound) | |
621 { | |
622 ALCcontext *pContext; | |
623 | |
624 pContext = alcGetCurrentContext(); | |
625 if (pContext) | |
626 { | |
627 SuspendContext(pContext); | |
628 | |
629 if (flSpeedOfSound > 0.0f) | |
630 pContext->flSpeedOfSound = flSpeedOfSound; | |
631 else | |
632 alSetError(AL_INVALID_VALUE); | |
633 | |
634 ProcessContext(pContext); | |
635 } | |
636 else | |
637 { | |
638 alSetError(AL_INVALID_OPERATION); | |
639 } | |
640 | |
641 return; | |
642 } | |
643 | |
644 ALAPI ALvoid ALAPIENTRY alDistanceModel(ALenum value) | |
645 { | |
646 ALCcontext *Context; | |
647 | |
648 Context=alcGetCurrentContext(); | |
649 if (Context) | |
650 { | |
651 SuspendContext(Context); | |
652 | |
653 switch (value) | |
654 { | |
655 case AL_NONE: | |
656 case AL_INVERSE_DISTANCE: | |
657 case AL_INVERSE_DISTANCE_CLAMPED: | |
658 case AL_LINEAR_DISTANCE: | |
659 case AL_LINEAR_DISTANCE_CLAMPED: | |
660 case AL_EXPONENT_DISTANCE: | |
661 case AL_EXPONENT_DISTANCE_CLAMPED: | |
662 Context->DistanceModel = value; | |
663 break; | |
664 | |
665 default: | |
666 alSetError(AL_INVALID_VALUE); | |
667 break; | |
668 } | |
669 | |
670 ProcessContext(Context); | |
671 } | |
672 else | |
673 { | |
674 // Invalid Context | |
675 alSetError(AL_INVALID_OPERATION); | |
676 } | |
677 | |
678 return; | |
679 } |