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
26 #include "alListener.h"
29 AL_API ALvoid AL_APIENTRY
alListenerf(ALenum param
, ALfloat value
)
33 context
= GetContextRef();
39 if(!(value
>= 0.0f
&& isfinite(value
)))
40 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
42 context
->Listener
->Gain
= value
;
43 ATOMIC_STORE(&context
->UpdateSources
, AL_TRUE
);
46 case AL_METERS_PER_UNIT
:
47 if(!(value
>= 0.0f
&& isfinite(value
)))
48 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
50 context
->Listener
->MetersPerUnit
= value
;
51 ATOMIC_STORE(&context
->UpdateSources
, AL_TRUE
);
55 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
59 ALCcontext_DecRef(context
);
63 AL_API ALvoid AL_APIENTRY
alListener3f(ALenum param
, ALfloat value1
, ALfloat value2
, ALfloat value3
)
67 context
= GetContextRef();
73 if(!(isfinite(value1
) && isfinite(value2
) && isfinite(value3
)))
74 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
77 aluVectorSet(&context
->Listener
->Position
, value1
, value2
, value3
, 1.0f
);
78 ATOMIC_STORE(&context
->UpdateSources
, AL_TRUE
);
79 UnlockContext(context
);
83 if(!(isfinite(value1
) && isfinite(value2
) && isfinite(value3
)))
84 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
87 aluVectorSet(&context
->Listener
->Velocity
, value1
, value2
, value3
, 0.0f
);
88 ATOMIC_STORE(&context
->UpdateSources
, AL_TRUE
);
89 UnlockContext(context
);
93 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
97 ALCcontext_DecRef(context
);
101 AL_API ALvoid AL_APIENTRY
alListenerfv(ALenum param
, const ALfloat
*values
)
110 case AL_METERS_PER_UNIT
:
111 alListenerf(param
, values
[0]);
116 alListener3f(param
, values
[0], values
[1], values
[2]);
121 context
= GetContextRef();
125 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
129 if(!(isfinite(values
[0]) && isfinite(values
[1]) && isfinite(values
[2]) &&
130 isfinite(values
[3]) && isfinite(values
[4]) && isfinite(values
[5])))
131 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
133 LockContext(context
);
135 context
->Listener
->Forward
[0] = values
[0];
136 context
->Listener
->Forward
[1] = values
[1];
137 context
->Listener
->Forward
[2] = values
[2];
138 context
->Listener
->Up
[0] = values
[3];
139 context
->Listener
->Up
[1] = values
[4];
140 context
->Listener
->Up
[2] = values
[5];
141 ATOMIC_STORE(&context
->UpdateSources
, AL_TRUE
);
142 UnlockContext(context
);
146 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
150 ALCcontext_DecRef(context
);
154 AL_API ALvoid AL_APIENTRY
alListeneri(ALenum param
, ALint
UNUSED(value
))
158 context
= GetContextRef();
164 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
168 ALCcontext_DecRef(context
);
172 AL_API
void AL_APIENTRY
alListener3i(ALenum param
, ALint value1
, ALint value2
, ALint value3
)
180 alListener3f(param
, (ALfloat
)value1
, (ALfloat
)value2
, (ALfloat
)value3
);
184 context
= GetContextRef();
190 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
194 ALCcontext_DecRef(context
);
198 AL_API
void AL_APIENTRY
alListeneriv(ALenum param
, const ALint
*values
)
209 alListener3f(param
, (ALfloat
)values
[0], (ALfloat
)values
[1], (ALfloat
)values
[2]);
213 fvals
[0] = (ALfloat
)values
[0];
214 fvals
[1] = (ALfloat
)values
[1];
215 fvals
[2] = (ALfloat
)values
[2];
216 fvals
[3] = (ALfloat
)values
[3];
217 fvals
[4] = (ALfloat
)values
[4];
218 fvals
[5] = (ALfloat
)values
[5];
219 alListenerfv(param
, fvals
);
224 context
= GetContextRef();
228 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
232 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
236 ALCcontext_DecRef(context
);
240 AL_API ALvoid AL_APIENTRY
alGetListenerf(ALenum param
, ALfloat
*value
)
244 context
= GetContextRef();
248 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
252 *value
= context
->Listener
->Gain
;
255 case AL_METERS_PER_UNIT
:
256 *value
= context
->Listener
->MetersPerUnit
;
260 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
264 ALCcontext_DecRef(context
);
268 AL_API ALvoid AL_APIENTRY
alGetListener3f(ALenum param
, ALfloat
*value1
, ALfloat
*value2
, ALfloat
*value3
)
272 context
= GetContextRef();
275 if(!(value1
&& value2
&& value3
))
276 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
280 LockContext(context
);
281 *value1
= context
->Listener
->Position
.v
[0];
282 *value2
= context
->Listener
->Position
.v
[1];
283 *value3
= context
->Listener
->Position
.v
[2];
284 UnlockContext(context
);
288 LockContext(context
);
289 *value1
= context
->Listener
->Velocity
.v
[0];
290 *value2
= context
->Listener
->Velocity
.v
[1];
291 *value3
= context
->Listener
->Velocity
.v
[2];
292 UnlockContext(context
);
296 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
300 ALCcontext_DecRef(context
);
304 AL_API ALvoid AL_APIENTRY
alGetListenerfv(ALenum param
, ALfloat
*values
)
311 case AL_METERS_PER_UNIT
:
312 alGetListenerf(param
, values
);
317 alGetListener3f(param
, values
+0, values
+1, values
+2);
321 context
= GetContextRef();
325 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
329 LockContext(context
);
331 values
[0] = context
->Listener
->Forward
[0];
332 values
[1] = context
->Listener
->Forward
[1];
333 values
[2] = context
->Listener
->Forward
[2];
334 values
[3] = context
->Listener
->Up
[0];
335 values
[4] = context
->Listener
->Up
[1];
336 values
[5] = context
->Listener
->Up
[2];
337 UnlockContext(context
);
341 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
345 ALCcontext_DecRef(context
);
349 AL_API ALvoid AL_APIENTRY
alGetListeneri(ALenum param
, ALint
*value
)
353 context
= GetContextRef();
357 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
361 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
365 ALCcontext_DecRef(context
);
369 AL_API
void AL_APIENTRY
alGetListener3i(ALenum param
, ALint
*value1
, ALint
*value2
, ALint
*value3
)
373 context
= GetContextRef();
376 if(!(value1
&& value2
&& value3
))
377 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
381 LockContext(context
);
382 *value1
= (ALint
)context
->Listener
->Position
.v
[0];
383 *value2
= (ALint
)context
->Listener
->Position
.v
[1];
384 *value3
= (ALint
)context
->Listener
->Position
.v
[2];
385 UnlockContext(context
);
389 LockContext(context
);
390 *value1
= (ALint
)context
->Listener
->Velocity
.v
[0];
391 *value2
= (ALint
)context
->Listener
->Velocity
.v
[1];
392 *value3
= (ALint
)context
->Listener
->Velocity
.v
[2];
393 UnlockContext(context
);
397 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
401 ALCcontext_DecRef(context
);
405 AL_API
void AL_APIENTRY
alGetListeneriv(ALenum param
, ALint
* values
)
413 alGetListener3i(param
, values
+0, values
+1, values
+2);
417 context
= GetContextRef();
421 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
425 LockContext(context
);
427 values
[0] = (ALint
)context
->Listener
->Forward
[0];
428 values
[1] = (ALint
)context
->Listener
->Forward
[1];
429 values
[2] = (ALint
)context
->Listener
->Forward
[2];
430 values
[3] = (ALint
)context
->Listener
->Up
[0];
431 values
[4] = (ALint
)context
->Listener
->Up
[1];
432 values
[5] = (ALint
)context
->Listener
->Up
[2];
433 UnlockContext(context
);
437 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
441 ALCcontext_DecRef(context
);