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
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 context
->Listener
->Position
[0] = value1
;
78 context
->Listener
->Position
[1] = value2
;
79 context
->Listener
->Position
[2] = value3
;
80 ATOMIC_STORE(&context
->UpdateSources
, AL_TRUE
);
81 UnlockContext(context
);
85 if(!(isfinite(value1
) && isfinite(value2
) && isfinite(value3
)))
86 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
89 context
->Listener
->Velocity
[0] = value1
;
90 context
->Listener
->Velocity
[1] = value2
;
91 context
->Listener
->Velocity
[2] = value3
;
92 ATOMIC_STORE(&context
->UpdateSources
, AL_TRUE
);
93 UnlockContext(context
);
97 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
101 ALCcontext_DecRef(context
);
105 AL_API ALvoid AL_APIENTRY
alListenerfv(ALenum param
, const ALfloat
*values
)
114 case AL_METERS_PER_UNIT
:
115 alListenerf(param
, values
[0]);
120 alListener3f(param
, values
[0], values
[1], values
[2]);
125 context
= GetContextRef();
129 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
133 if(!(isfinite(values
[0]) && isfinite(values
[1]) && isfinite(values
[2]) &&
134 isfinite(values
[3]) && isfinite(values
[4]) && isfinite(values
[5])))
135 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
137 LockContext(context
);
139 context
->Listener
->Forward
[0] = values
[0];
140 context
->Listener
->Forward
[1] = values
[1];
141 context
->Listener
->Forward
[2] = values
[2];
142 context
->Listener
->Up
[0] = values
[3];
143 context
->Listener
->Up
[1] = values
[4];
144 context
->Listener
->Up
[2] = values
[5];
145 ATOMIC_STORE(&context
->UpdateSources
, AL_TRUE
);
146 UnlockContext(context
);
150 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
154 ALCcontext_DecRef(context
);
158 AL_API ALvoid AL_APIENTRY
alListeneri(ALenum param
, ALint
UNUSED(value
))
162 context
= GetContextRef();
168 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
172 ALCcontext_DecRef(context
);
176 AL_API
void AL_APIENTRY
alListener3i(ALenum param
, ALint value1
, ALint value2
, ALint value3
)
184 alListener3f(param
, (ALfloat
)value1
, (ALfloat
)value2
, (ALfloat
)value3
);
188 context
= GetContextRef();
194 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
198 ALCcontext_DecRef(context
);
202 AL_API
void AL_APIENTRY
alListeneriv(ALenum param
, const ALint
*values
)
213 alListener3f(param
, (ALfloat
)values
[0], (ALfloat
)values
[1], (ALfloat
)values
[2]);
217 fvals
[0] = (ALfloat
)values
[0];
218 fvals
[1] = (ALfloat
)values
[1];
219 fvals
[2] = (ALfloat
)values
[2];
220 fvals
[3] = (ALfloat
)values
[3];
221 fvals
[4] = (ALfloat
)values
[4];
222 fvals
[5] = (ALfloat
)values
[5];
223 alListenerfv(param
, fvals
);
228 context
= GetContextRef();
232 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
236 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
240 ALCcontext_DecRef(context
);
244 AL_API ALvoid AL_APIENTRY
alGetListenerf(ALenum param
, ALfloat
*value
)
248 context
= GetContextRef();
252 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
256 *value
= context
->Listener
->Gain
;
259 case AL_METERS_PER_UNIT
:
260 *value
= context
->Listener
->MetersPerUnit
;
264 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
268 ALCcontext_DecRef(context
);
272 AL_API ALvoid AL_APIENTRY
alGetListener3f(ALenum param
, ALfloat
*value1
, ALfloat
*value2
, ALfloat
*value3
)
276 context
= GetContextRef();
279 if(!(value1
&& value2
&& value3
))
280 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
284 LockContext(context
);
285 *value1
= context
->Listener
->Position
[0];
286 *value2
= context
->Listener
->Position
[1];
287 *value3
= context
->Listener
->Position
[2];
288 UnlockContext(context
);
292 LockContext(context
);
293 *value1
= context
->Listener
->Velocity
[0];
294 *value2
= context
->Listener
->Velocity
[1];
295 *value3
= context
->Listener
->Velocity
[2];
296 UnlockContext(context
);
300 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
304 ALCcontext_DecRef(context
);
308 AL_API ALvoid AL_APIENTRY
alGetListenerfv(ALenum param
, ALfloat
*values
)
315 case AL_METERS_PER_UNIT
:
316 alGetListenerf(param
, values
);
321 alGetListener3f(param
, values
+0, values
+1, values
+2);
325 context
= GetContextRef();
329 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
333 LockContext(context
);
335 values
[0] = context
->Listener
->Forward
[0];
336 values
[1] = context
->Listener
->Forward
[1];
337 values
[2] = context
->Listener
->Forward
[2];
338 values
[3] = context
->Listener
->Up
[0];
339 values
[4] = context
->Listener
->Up
[1];
340 values
[5] = context
->Listener
->Up
[2];
341 UnlockContext(context
);
345 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
349 ALCcontext_DecRef(context
);
353 AL_API ALvoid AL_APIENTRY
alGetListeneri(ALenum param
, ALint
*value
)
357 context
= GetContextRef();
361 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
365 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
369 ALCcontext_DecRef(context
);
373 AL_API
void AL_APIENTRY
alGetListener3i(ALenum param
, ALint
*value1
, ALint
*value2
, ALint
*value3
)
377 context
= GetContextRef();
380 if(!(value1
&& value2
&& value3
))
381 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
385 LockContext(context
);
386 *value1
= (ALint
)context
->Listener
->Position
[0];
387 *value2
= (ALint
)context
->Listener
->Position
[1];
388 *value3
= (ALint
)context
->Listener
->Position
[2];
389 UnlockContext(context
);
393 LockContext(context
);
394 *value1
= (ALint
)context
->Listener
->Velocity
[0];
395 *value2
= (ALint
)context
->Listener
->Velocity
[1];
396 *value3
= (ALint
)context
->Listener
->Velocity
[2];
397 UnlockContext(context
);
401 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
405 ALCcontext_DecRef(context
);
409 AL_API
void AL_APIENTRY
alGetListeneriv(ALenum param
, ALint
* values
)
417 alGetListener3i(param
, values
+0, values
+1, values
+2);
421 context
= GetContextRef();
425 SET_ERROR_AND_GOTO(context
, AL_INVALID_VALUE
, done
);
429 LockContext(context
);
431 values
[0] = (ALint
)context
->Listener
->Forward
[0];
432 values
[1] = (ALint
)context
->Listener
->Forward
[1];
433 values
[2] = (ALint
)context
->Listener
->Forward
[2];
434 values
[3] = (ALint
)context
->Listener
->Up
[0];
435 values
[4] = (ALint
)context
->Listener
->Up
[1];
436 values
[5] = (ALint
)context
->Listener
->Up
[2];
437 UnlockContext(context
);
441 SET_ERROR_AND_GOTO(context
, AL_INVALID_ENUM
, done
);
445 ALCcontext_DecRef(context
);