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.
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.
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.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 * Or go to http://www.gnu.org/copyleft/lgpl.html
30 #include "alAuxEffectSlot.h"
32 #include "backends/base.h"
35 static const ALchar alVendor
[] = "OpenAL Community";
36 static const ALchar alVersion
[] = "1.1 ALSOFT "ALSOFT_VERSION
;
37 static const ALchar alRenderer
[] = "OpenAL Soft";
40 static const ALchar alNoError
[] = "No Error";
41 static const ALchar alErrInvalidName
[] = "Invalid Name";
42 static const ALchar alErrInvalidEnum
[] = "Invalid Enum";
43 static const ALchar alErrInvalidValue
[] = "Invalid Value";
44 static const ALchar alErrInvalidOp
[] = "Invalid Operation";
45 static const ALchar alErrOutOfMemory
[] = "Out of Memory";
47 AL_API ALvoid AL_APIENTRY
alEnable(ALenum capability
)
51 context
= GetContextRef();
56 case AL_SOURCE_DISTANCE_MODEL
:
57 context
->SourceDistanceModel
= AL_TRUE
;
58 ATOMIC_STORE(&context
->UpdateSources
, AL_TRUE
);
62 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
66 ALCcontext_DecRef(context
);
69 AL_API ALvoid AL_APIENTRY
alDisable(ALenum capability
)
73 context
= GetContextRef();
78 case AL_SOURCE_DISTANCE_MODEL
:
79 context
->SourceDistanceModel
= AL_FALSE
;
80 ATOMIC_STORE(&context
->UpdateSources
, AL_TRUE
);
84 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
88 ALCcontext_DecRef(context
);
91 AL_API ALboolean AL_APIENTRY
alIsEnabled(ALenum capability
)
94 ALboolean value
=AL_FALSE
;
96 context
= GetContextRef();
97 if(!context
) return AL_FALSE
;
101 case AL_SOURCE_DISTANCE_MODEL
:
102 value
= context
->SourceDistanceModel
;
106 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
110 ALCcontext_DecRef(context
);
115 AL_API ALboolean AL_APIENTRY
alGetBoolean(ALenum pname
)
118 ALboolean value
=AL_FALSE
;
120 context
= GetContextRef();
121 if(!context
) return AL_FALSE
;
125 case AL_DOPPLER_FACTOR
:
126 if(context
->DopplerFactor
!= 0.0f
)
130 case AL_DOPPLER_VELOCITY
:
131 if(context
->DopplerVelocity
!= 0.0f
)
135 case AL_DISTANCE_MODEL
:
136 if(context
->DistanceModel
== AL_INVERSE_DISTANCE_CLAMPED
)
140 case AL_SPEED_OF_SOUND
:
141 if(context
->SpeedOfSound
!= 0.0f
)
145 case AL_DEFERRED_UPDATES_SOFT
:
146 value
= context
->DeferUpdates
;
150 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
154 ALCcontext_DecRef(context
);
159 AL_API ALdouble AL_APIENTRY
alGetDouble(ALenum pname
)
162 ALdouble value
= 0.0;
164 context
= GetContextRef();
165 if(!context
) return 0.0;
169 case AL_DOPPLER_FACTOR
:
170 value
= (ALdouble
)context
->DopplerFactor
;
173 case AL_DOPPLER_VELOCITY
:
174 value
= (ALdouble
)context
->DopplerVelocity
;
177 case AL_DISTANCE_MODEL
:
178 value
= (ALdouble
)context
->DistanceModel
;
181 case AL_SPEED_OF_SOUND
:
182 value
= (ALdouble
)context
->SpeedOfSound
;
185 case AL_DEFERRED_UPDATES_SOFT
:
186 value
= (ALdouble
)context
->DeferUpdates
;
190 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
194 ALCcontext_DecRef(context
);
199 AL_API ALfloat AL_APIENTRY
alGetFloat(ALenum pname
)
202 ALfloat value
= 0.0f
;
204 context
= GetContextRef();
205 if(!context
) return 0.0f
;
209 case AL_DOPPLER_FACTOR
:
210 value
= context
->DopplerFactor
;
213 case AL_DOPPLER_VELOCITY
:
214 value
= context
->DopplerVelocity
;
217 case AL_DISTANCE_MODEL
:
218 value
= (ALfloat
)context
->DistanceModel
;
221 case AL_SPEED_OF_SOUND
:
222 value
= context
->SpeedOfSound
;
225 case AL_DEFERRED_UPDATES_SOFT
:
226 value
= (ALfloat
)context
->DeferUpdates
;
230 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
234 ALCcontext_DecRef(context
);
239 AL_API ALint AL_APIENTRY
alGetInteger(ALenum pname
)
244 context
= GetContextRef();
245 if(!context
) return 0;
249 case AL_DOPPLER_FACTOR
:
250 value
= (ALint
)context
->DopplerFactor
;
253 case AL_DOPPLER_VELOCITY
:
254 value
= (ALint
)context
->DopplerVelocity
;
257 case AL_DISTANCE_MODEL
:
258 value
= (ALint
)context
->DistanceModel
;
261 case AL_SPEED_OF_SOUND
:
262 value
= (ALint
)context
->SpeedOfSound
;
265 case AL_DEFERRED_UPDATES_SOFT
:
266 value
= (ALint
)context
->DeferUpdates
;
270 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
274 ALCcontext_DecRef(context
);
279 AL_API ALint64SOFT AL_APIENTRY
alGetInteger64SOFT(ALenum pname
)
282 ALint64SOFT value
= 0;
284 context
= GetContextRef();
285 if(!context
) return 0;
289 case AL_DOPPLER_FACTOR
:
290 value
= (ALint64SOFT
)context
->DopplerFactor
;
293 case AL_DOPPLER_VELOCITY
:
294 value
= (ALint64SOFT
)context
->DopplerVelocity
;
297 case AL_DISTANCE_MODEL
:
298 value
= (ALint64SOFT
)context
->DistanceModel
;
301 case AL_SPEED_OF_SOUND
:
302 value
= (ALint64SOFT
)context
->SpeedOfSound
;
305 case AL_DEFERRED_UPDATES_SOFT
:
306 value
= (ALint64SOFT
)context
->DeferUpdates
;
310 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
314 ALCcontext_DecRef(context
);
319 AL_API ALvoid AL_APIENTRY
alGetBooleanv(ALenum pname
, ALboolean
*values
)
327 case AL_DOPPLER_FACTOR
:
328 case AL_DOPPLER_VELOCITY
:
329 case AL_DISTANCE_MODEL
:
330 case AL_SPEED_OF_SOUND
:
331 case AL_DEFERRED_UPDATES_SOFT
:
332 values
[0] = alGetBoolean(pname
);
337 context
= GetContextRef();
341 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
345 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
349 ALCcontext_DecRef(context
);
352 AL_API ALvoid AL_APIENTRY
alGetDoublev(ALenum pname
, ALdouble
*values
)
360 case AL_DOPPLER_FACTOR
:
361 case AL_DOPPLER_VELOCITY
:
362 case AL_DISTANCE_MODEL
:
363 case AL_SPEED_OF_SOUND
:
364 case AL_DEFERRED_UPDATES_SOFT
:
365 values
[0] = alGetDouble(pname
);
370 context
= GetContextRef();
374 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
378 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
382 ALCcontext_DecRef(context
);
385 AL_API ALvoid AL_APIENTRY
alGetFloatv(ALenum pname
, ALfloat
*values
)
393 case AL_DOPPLER_FACTOR
:
394 case AL_DOPPLER_VELOCITY
:
395 case AL_DISTANCE_MODEL
:
396 case AL_SPEED_OF_SOUND
:
397 case AL_DEFERRED_UPDATES_SOFT
:
398 values
[0] = alGetFloat(pname
);
403 context
= GetContextRef();
407 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
411 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
415 ALCcontext_DecRef(context
);
418 AL_API ALvoid AL_APIENTRY
alGetIntegerv(ALenum pname
, ALint
*values
)
426 case AL_DOPPLER_FACTOR
:
427 case AL_DOPPLER_VELOCITY
:
428 case AL_DISTANCE_MODEL
:
429 case AL_SPEED_OF_SOUND
:
430 case AL_DEFERRED_UPDATES_SOFT
:
431 values
[0] = alGetInteger(pname
);
436 context
= GetContextRef();
442 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
446 ALCcontext_DecRef(context
);
449 AL_API
void AL_APIENTRY
alGetInteger64vSOFT(ALenum pname
, ALint64SOFT
*values
)
457 case AL_DOPPLER_FACTOR
:
458 case AL_DOPPLER_VELOCITY
:
459 case AL_DISTANCE_MODEL
:
460 case AL_SPEED_OF_SOUND
:
461 case AL_DEFERRED_UPDATES_SOFT
:
462 values
[0] = alGetInteger64SOFT(pname
);
467 context
= GetContextRef();
473 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
477 ALCcontext_DecRef(context
);
480 AL_API
const ALchar
* AL_APIENTRY
alGetString(ALenum pname
)
482 const ALchar
*value
= NULL
;
485 context
= GetContextRef();
486 if(!context
) return NULL
;
503 value
= context
->ExtensionList
;
510 case AL_INVALID_NAME
:
511 value
= alErrInvalidName
;
514 case AL_INVALID_ENUM
:
515 value
= alErrInvalidEnum
;
518 case AL_INVALID_VALUE
:
519 value
= alErrInvalidValue
;
522 case AL_INVALID_OPERATION
:
523 value
= alErrInvalidOp
;
526 case AL_OUT_OF_MEMORY
:
527 value
= alErrOutOfMemory
;
531 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
535 ALCcontext_DecRef(context
);
540 AL_API ALvoid AL_APIENTRY
alDopplerFactor(ALfloat value
)
544 context
= GetContextRef();
547 if(!(value
>= 0.0f
&& isfinite(value
)))
548 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
550 context
->DopplerFactor
= value
;
551 ATOMIC_STORE(&context
->UpdateSources
, AL_TRUE
);
554 ALCcontext_DecRef(context
);
557 AL_API ALvoid AL_APIENTRY
alDopplerVelocity(ALfloat value
)
561 context
= GetContextRef();
564 if(!(value
>= 0.0f
&& isfinite(value
)))
565 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
567 context
->DopplerVelocity
= value
;
568 ATOMIC_STORE(&context
->UpdateSources
, AL_TRUE
);
571 ALCcontext_DecRef(context
);
574 AL_API ALvoid AL_APIENTRY
alSpeedOfSound(ALfloat value
)
578 context
= GetContextRef();
581 if(!(value
> 0.0f
&& isfinite(value
)))
582 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
584 context
->SpeedOfSound
= value
;
585 ATOMIC_STORE(&context
->UpdateSources
, AL_TRUE
);
588 ALCcontext_DecRef(context
);
591 AL_API ALvoid AL_APIENTRY
alDistanceModel(ALenum value
)
595 context
= GetContextRef();
598 if(!(value
== AL_INVERSE_DISTANCE
|| value
== AL_INVERSE_DISTANCE_CLAMPED
||
599 value
== AL_LINEAR_DISTANCE
|| value
== AL_LINEAR_DISTANCE_CLAMPED
||
600 value
== AL_EXPONENT_DISTANCE
|| value
== AL_EXPONENT_DISTANCE_CLAMPED
||
602 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
604 context
->DistanceModel
= value
;
605 if(!context
->SourceDistanceModel
)
606 ATOMIC_STORE(&context
->UpdateSources
, AL_TRUE
);
609 ALCcontext_DecRef(context
);
613 AL_API ALvoid AL_APIENTRY
alDeferUpdatesSOFT(void)
617 context
= GetContextRef();
620 ALCcontext_DeferUpdates(context
);
622 ALCcontext_DecRef(context
);
625 AL_API ALvoid AL_APIENTRY
alProcessUpdatesSOFT(void)
629 context
= GetContextRef();
632 ALCcontext_ProcessUpdates(context
);
634 ALCcontext_DecRef(context
);