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., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 * Or go to http://www.gnu.org/copyleft/lgpl.html
30 #include "alDatabuffer.h"
32 static const ALchar alVendor
[] = "OpenAL Community";
33 static const ALchar alVersion
[] = "1.1 ALSOFT "ALSOFT_VERSION
;
34 static const ALchar alRenderer
[] = "OpenAL Soft";
37 static const ALchar alNoError
[] = "No Error";
38 static const ALchar alErrInvalidName
[] = "Invalid Name";
39 static const ALchar alErrInvalidEnum
[] = "Invalid Enum";
40 static const ALchar alErrInvalidValue
[] = "Invalid Value";
41 static const ALchar alErrInvalidOp
[] = "Invalid Operation";
42 static const ALchar alErrOutOfMemory
[] = "Out of Memory";
44 ALAPI ALvoid ALAPIENTRY
alEnable(ALenum capability
)
48 Context
= GetContextSuspended();
54 alSetError(AL_INVALID_ENUM
);
58 ProcessContext(Context
);
61 ALAPI ALvoid ALAPIENTRY
alDisable(ALenum capability
)
65 Context
= GetContextSuspended();
71 alSetError(AL_INVALID_ENUM
);
75 ProcessContext(Context
);
78 ALAPI ALboolean ALAPIENTRY
alIsEnabled(ALenum capability
)
81 ALboolean value
=AL_FALSE
;
83 Context
= GetContextSuspended();
84 if(!Context
) return AL_FALSE
;
89 alSetError(AL_INVALID_ENUM
);
93 ProcessContext(Context
);
98 ALAPI ALboolean ALAPIENTRY
alGetBoolean(ALenum pname
)
101 ALboolean value
=AL_FALSE
;
103 Context
= GetContextSuspended();
104 if(!Context
) return AL_FALSE
;
108 case AL_DOPPLER_FACTOR
:
109 if(Context
->DopplerFactor
!= 0.0f
)
113 case AL_DOPPLER_VELOCITY
:
114 if(Context
->DopplerVelocity
!= 0.0f
)
118 case AL_DISTANCE_MODEL
:
119 if(Context
->DistanceModel
== AL_INVERSE_DISTANCE_CLAMPED
)
123 case AL_SPEED_OF_SOUND
:
124 if(Context
->flSpeedOfSound
!= 0.0f
)
129 alSetError(AL_INVALID_ENUM
);
133 ProcessContext(Context
);
138 ALAPI ALdouble ALAPIENTRY
alGetDouble(ALenum pname
)
141 ALdouble value
= 0.0;
143 Context
= GetContextSuspended();
144 if(!Context
) return 0.0;
148 case AL_DOPPLER_FACTOR
:
149 value
= (double)Context
->DopplerFactor
;
152 case AL_DOPPLER_VELOCITY
:
153 value
= (double)Context
->DopplerVelocity
;
156 case AL_DISTANCE_MODEL
:
157 value
= (double)Context
->DistanceModel
;
160 case AL_SPEED_OF_SOUND
:
161 value
= (double)Context
->flSpeedOfSound
;
165 alSetError(AL_INVALID_ENUM
);
169 ProcessContext(Context
);
174 ALAPI ALfloat ALAPIENTRY
alGetFloat(ALenum pname
)
177 ALfloat value
= 0.0f
;
179 Context
= GetContextSuspended();
180 if(!Context
) return 0.0f
;
184 case AL_DOPPLER_FACTOR
:
185 value
= Context
->DopplerFactor
;
188 case AL_DOPPLER_VELOCITY
:
189 value
= Context
->DopplerVelocity
;
192 case AL_DISTANCE_MODEL
:
193 value
= (float)Context
->DistanceModel
;
196 case AL_SPEED_OF_SOUND
:
197 value
= Context
->flSpeedOfSound
;
201 alSetError(AL_INVALID_ENUM
);
205 ProcessContext(Context
);
210 ALAPI ALint ALAPIENTRY
alGetInteger(ALenum pname
)
215 Context
= GetContextSuspended();
216 if(!Context
) return 0;
220 case AL_DOPPLER_FACTOR
:
221 value
= (ALint
)Context
->DopplerFactor
;
224 case AL_DOPPLER_VELOCITY
:
225 value
= (ALint
)Context
->DopplerVelocity
;
228 case AL_DISTANCE_MODEL
:
229 value
= (ALint
)Context
->DistanceModel
;
232 case AL_SPEED_OF_SOUND
:
233 value
= (ALint
)Context
->flSpeedOfSound
;
236 case AL_SAMPLE_SOURCE_EXT
:
237 if(Context
->SampleSource
)
238 value
= (ALint
)Context
->SampleSource
->databuffer
;
243 case AL_SAMPLE_SINK_EXT
:
244 if(Context
->SampleSink
)
245 value
= (ALint
)Context
->SampleSink
->databuffer
;
251 alSetError(AL_INVALID_ENUM
);
255 ProcessContext(Context
);
260 ALAPI ALvoid ALAPIENTRY
alGetBooleanv(ALenum pname
,ALboolean
*data
)
264 Context
= GetContextSuspended();
271 case AL_DOPPLER_FACTOR
:
272 *data
= (ALboolean
)((Context
->DopplerFactor
!= 0.0f
) ? AL_TRUE
: AL_FALSE
);
275 case AL_DOPPLER_VELOCITY
:
276 *data
= (ALboolean
)((Context
->DopplerVelocity
!= 0.0f
) ? AL_TRUE
: AL_FALSE
);
279 case AL_DISTANCE_MODEL
:
280 *data
= (ALboolean
)((Context
->DistanceModel
== AL_INVERSE_DISTANCE_CLAMPED
) ? AL_TRUE
: AL_FALSE
);
283 case AL_SPEED_OF_SOUND
:
284 *data
= (ALboolean
)((Context
->flSpeedOfSound
!= 0.0f
) ? AL_TRUE
: AL_FALSE
);
288 alSetError(AL_INVALID_ENUM
);
294 // data is a NULL pointer
295 alSetError(AL_INVALID_VALUE
);
298 ProcessContext(Context
);
301 ALAPI ALvoid ALAPIENTRY
alGetDoublev(ALenum pname
,ALdouble
*data
)
305 Context
= GetContextSuspended();
312 case AL_DOPPLER_FACTOR
:
313 *data
= (double)Context
->DopplerFactor
;
316 case AL_DOPPLER_VELOCITY
:
317 *data
= (double)Context
->DopplerVelocity
;
320 case AL_DISTANCE_MODEL
:
321 *data
= (double)Context
->DistanceModel
;
324 case AL_SPEED_OF_SOUND
:
325 *data
= (double)Context
->flSpeedOfSound
;
329 alSetError(AL_INVALID_ENUM
);
335 // data is a NULL pointer
336 alSetError(AL_INVALID_VALUE
);
339 ProcessContext(Context
);
342 ALAPI ALvoid ALAPIENTRY
alGetFloatv(ALenum pname
,ALfloat
*data
)
346 Context
= GetContextSuspended();
353 case AL_DOPPLER_FACTOR
:
354 *data
= Context
->DopplerFactor
;
357 case AL_DOPPLER_VELOCITY
:
358 *data
= Context
->DopplerVelocity
;
361 case AL_DISTANCE_MODEL
:
362 *data
= (float)Context
->DistanceModel
;
365 case AL_SPEED_OF_SOUND
:
366 *data
= Context
->flSpeedOfSound
;
370 alSetError(AL_INVALID_ENUM
);
376 // data is a NULL pointer
377 alSetError(AL_INVALID_VALUE
);
380 ProcessContext(Context
);
383 ALAPI ALvoid ALAPIENTRY
alGetIntegerv(ALenum pname
,ALint
*data
)
387 Context
= GetContextSuspended();
394 case AL_DOPPLER_FACTOR
:
395 *data
= (ALint
)Context
->DopplerFactor
;
398 case AL_DOPPLER_VELOCITY
:
399 *data
= (ALint
)Context
->DopplerVelocity
;
402 case AL_DISTANCE_MODEL
:
403 *data
= (ALint
)Context
->DistanceModel
;
406 case AL_SPEED_OF_SOUND
:
407 *data
= (ALint
)Context
->flSpeedOfSound
;
410 case AL_SAMPLE_SOURCE_EXT
:
411 if(Context
->SampleSource
)
412 *data
= (ALint
)Context
->SampleSource
->databuffer
;
417 case AL_SAMPLE_SINK_EXT
:
418 if(Context
->SampleSink
)
419 *data
= (ALint
)Context
->SampleSink
->databuffer
;
425 alSetError(AL_INVALID_ENUM
);
431 // data is a NULL pointer
432 alSetError(AL_INVALID_VALUE
);
435 ProcessContext(Context
);
438 ALAPI
const ALchar
* ALAPIENTRY
alGetString(ALenum pname
)
441 ALCcontext
*pContext
;
443 pContext
= GetContextSuspended();
444 if(!pContext
) return NULL
;
461 value
=pContext
->ExtensionList
;//alExtensions;
468 case AL_INVALID_NAME
:
469 value
=alErrInvalidName
;
472 case AL_INVALID_ENUM
:
473 value
=alErrInvalidEnum
;
476 case AL_INVALID_VALUE
:
477 value
=alErrInvalidValue
;
480 case AL_INVALID_OPERATION
:
481 value
=alErrInvalidOp
;
484 case AL_OUT_OF_MEMORY
:
485 value
=alErrOutOfMemory
;
490 alSetError(AL_INVALID_ENUM
);
494 ProcessContext(pContext
);
499 ALAPI ALvoid ALAPIENTRY
alDopplerFactor(ALfloat value
)
503 Context
= GetContextSuspended();
507 Context
->DopplerFactor
= value
;
509 alSetError(AL_INVALID_VALUE
);
511 ProcessContext(Context
);
514 ALAPI ALvoid ALAPIENTRY
alDopplerVelocity(ALfloat value
)
518 Context
= GetContextSuspended();
522 Context
->DopplerVelocity
=value
;
524 alSetError(AL_INVALID_VALUE
);
526 ProcessContext(Context
);
529 ALAPI ALvoid ALAPIENTRY
alSpeedOfSound(ALfloat flSpeedOfSound
)
531 ALCcontext
*pContext
;
533 pContext
= GetContextSuspended();
534 if(!pContext
) return;
536 if(flSpeedOfSound
> 0.0f
)
537 pContext
->flSpeedOfSound
= flSpeedOfSound
;
539 alSetError(AL_INVALID_VALUE
);
541 ProcessContext(pContext
);
544 ALAPI ALvoid ALAPIENTRY
alDistanceModel(ALenum value
)
549 Context
= GetContextSuspended();
555 case AL_INVERSE_DISTANCE
:
556 case AL_INVERSE_DISTANCE_CLAMPED
:
557 case AL_LINEAR_DISTANCE
:
558 case AL_LINEAR_DISTANCE_CLAMPED
:
559 case AL_EXPONENT_DISTANCE
:
560 case AL_EXPONENT_DISTANCE_CLAMPED
:
561 Context
->DistanceModel
= value
;
562 for(Source
= Context
->Source
;Source
!= NULL
;Source
= Source
->next
)
563 Source
->DistanceModel
= value
;
567 alSetError(AL_INVALID_VALUE
);
571 ProcessContext(Context
);