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();
41 CHECK_VALUE(Context
, value
>= 0.0f
&& isfinite(value
));
43 Context
->Listener
->Gain
= value
;
44 Context
->UpdateSources
= AL_TRUE
;
47 case AL_METERS_PER_UNIT
:
48 CHECK_VALUE(Context
, value
>= 0.0f
&& isfinite(value
));
50 Context
->Listener
->MetersPerUnit
= value
;
51 Context
->UpdateSources
= AL_TRUE
;
55 al_throwerr(Context
, AL_INVALID_ENUM
);
60 ALCcontext_DecRef(Context
);
64 AL_API ALvoid AL_APIENTRY
alListener3f(ALenum param
, ALfloat value1
, ALfloat value2
, ALfloat value3
)
68 Context
= GetContextRef();
76 CHECK_VALUE(Context
, isfinite(value1
) && isfinite(value2
) && isfinite(value3
));
79 Context
->Listener
->Position
[0] = value1
;
80 Context
->Listener
->Position
[1] = value2
;
81 Context
->Listener
->Position
[2] = value3
;
82 Context
->UpdateSources
= AL_TRUE
;
83 UnlockContext(Context
);
87 CHECK_VALUE(Context
, isfinite(value1
) && isfinite(value2
) && isfinite(value3
));
90 Context
->Listener
->Velocity
[0] = value1
;
91 Context
->Listener
->Velocity
[1] = value2
;
92 Context
->Listener
->Velocity
[2] = value3
;
93 Context
->UpdateSources
= AL_TRUE
;
94 UnlockContext(Context
);
98 al_throwerr(Context
, AL_INVALID_ENUM
);
103 ALCcontext_DecRef(Context
);
107 AL_API ALvoid AL_APIENTRY
alListenerfv(ALenum param
, const ALfloat
*values
)
116 case AL_METERS_PER_UNIT
:
117 alListenerf(param
, values
[0]);
122 alListener3f(param
, values
[0], values
[1], values
[2]);
127 Context
= GetContextRef();
132 CHECK_VALUE(Context
, values
);
136 CHECK_VALUE(Context
, isfinite(values
[0]) && isfinite(values
[1]) &&
137 isfinite(values
[2]) && isfinite(values
[3]) &&
138 isfinite(values
[4]) && isfinite(values
[5]));
140 LockContext(Context
);
142 Context
->Listener
->Forward
[0] = values
[0];
143 Context
->Listener
->Forward
[1] = values
[1];
144 Context
->Listener
->Forward
[2] = values
[2];
145 Context
->Listener
->Up
[0] = values
[3];
146 Context
->Listener
->Up
[1] = values
[4];
147 Context
->Listener
->Up
[2] = values
[5];
148 Context
->UpdateSources
= AL_TRUE
;
149 UnlockContext(Context
);
153 al_throwerr(Context
, AL_INVALID_ENUM
);
158 ALCcontext_DecRef(Context
);
162 AL_API ALvoid AL_APIENTRY
alListeneri(ALenum param
, ALint value
)
168 Context
= GetContextRef();
176 al_throwerr(Context
, AL_INVALID_ENUM
);
181 ALCcontext_DecRef(Context
);
185 AL_API
void AL_APIENTRY
alListener3i(ALenum param
, ALint value1
, ALint value2
, ALint value3
)
193 alListener3f(param
, (ALfloat
)value1
, (ALfloat
)value2
, (ALfloat
)value3
);
197 Context
= GetContextRef();
205 al_throwerr(Context
, AL_INVALID_ENUM
);
210 ALCcontext_DecRef(Context
);
214 AL_API
void AL_APIENTRY
alListeneriv(ALenum param
, const ALint
*values
)
225 alListener3f(param
, (ALfloat
)values
[0], (ALfloat
)values
[1], (ALfloat
)values
[2]);
229 fvals
[0] = (ALfloat
)values
[0];
230 fvals
[1] = (ALfloat
)values
[1];
231 fvals
[2] = (ALfloat
)values
[2];
232 fvals
[3] = (ALfloat
)values
[3];
233 fvals
[4] = (ALfloat
)values
[4];
234 fvals
[5] = (ALfloat
)values
[5];
235 alListenerfv(param
, fvals
);
240 Context
= GetContextRef();
245 CHECK_VALUE(Context
, values
);
249 al_throwerr(Context
, AL_INVALID_ENUM
);
254 ALCcontext_DecRef(Context
);
258 AL_API ALvoid AL_APIENTRY
alGetListenerf(ALenum param
, ALfloat
*value
)
262 Context
= GetContextRef();
267 CHECK_VALUE(Context
, value
);
271 *value
= Context
->Listener
->Gain
;
274 case AL_METERS_PER_UNIT
:
275 *value
= Context
->Listener
->MetersPerUnit
;
279 al_throwerr(Context
, AL_INVALID_ENUM
);
284 ALCcontext_DecRef(Context
);
288 AL_API ALvoid AL_APIENTRY
alGetListener3f(ALenum param
, ALfloat
*value1
, ALfloat
*value2
, ALfloat
*value3
)
292 Context
= GetContextRef();
297 CHECK_VALUE(Context
, value1
&& value2
&& value3
);
301 LockContext(Context
);
302 *value1
= Context
->Listener
->Position
[0];
303 *value2
= Context
->Listener
->Position
[1];
304 *value3
= Context
->Listener
->Position
[2];
305 UnlockContext(Context
);
309 LockContext(Context
);
310 *value1
= Context
->Listener
->Velocity
[0];
311 *value2
= Context
->Listener
->Velocity
[1];
312 *value3
= Context
->Listener
->Velocity
[2];
313 UnlockContext(Context
);
317 al_throwerr(Context
, AL_INVALID_ENUM
);
322 ALCcontext_DecRef(Context
);
326 AL_API ALvoid AL_APIENTRY
alGetListenerfv(ALenum param
, ALfloat
*values
)
333 case AL_METERS_PER_UNIT
:
334 alGetListenerf(param
, values
);
339 alGetListener3f(param
, values
+0, values
+1, values
+2);
343 Context
= GetContextRef();
348 CHECK_VALUE(Context
, values
);
352 LockContext(Context
);
354 values
[0] = Context
->Listener
->Forward
[0];
355 values
[1] = Context
->Listener
->Forward
[1];
356 values
[2] = Context
->Listener
->Forward
[2];
357 values
[3] = Context
->Listener
->Up
[0];
358 values
[4] = Context
->Listener
->Up
[1];
359 values
[5] = Context
->Listener
->Up
[2];
360 UnlockContext(Context
);
364 al_throwerr(Context
, AL_INVALID_ENUM
);
369 ALCcontext_DecRef(Context
);
373 AL_API ALvoid AL_APIENTRY
alGetListeneri(ALenum param
, ALint
*value
)
377 Context
= GetContextRef();
382 CHECK_VALUE(Context
, value
);
386 al_throwerr(Context
, AL_INVALID_ENUM
);
391 ALCcontext_DecRef(Context
);
395 AL_API
void AL_APIENTRY
alGetListener3i(ALenum param
, ALint
*value1
, ALint
*value2
, ALint
*value3
)
399 Context
= GetContextRef();
404 CHECK_VALUE(Context
, value1
&& value2
&& value3
);
408 LockContext(Context
);
409 *value1
= (ALint
)Context
->Listener
->Position
[0];
410 *value2
= (ALint
)Context
->Listener
->Position
[1];
411 *value3
= (ALint
)Context
->Listener
->Position
[2];
412 UnlockContext(Context
);
416 LockContext(Context
);
417 *value1
= (ALint
)Context
->Listener
->Velocity
[0];
418 *value2
= (ALint
)Context
->Listener
->Velocity
[1];
419 *value3
= (ALint
)Context
->Listener
->Velocity
[2];
420 UnlockContext(Context
);
424 al_throwerr(Context
, AL_INVALID_ENUM
);
429 ALCcontext_DecRef(Context
);
433 AL_API
void AL_APIENTRY
alGetListeneriv(ALenum param
, ALint
* values
)
441 alGetListener3i(param
, values
+0, values
+1, values
+2);
445 Context
= GetContextRef();
450 CHECK_VALUE(Context
, values
);
454 LockContext(Context
);
456 values
[0] = (ALint
)Context
->Listener
->Forward
[0];
457 values
[1] = (ALint
)Context
->Listener
->Forward
[1];
458 values
[2] = (ALint
)Context
->Listener
->Forward
[2];
459 values
[3] = (ALint
)Context
->Listener
->Up
[0];
460 values
[4] = (ALint
)Context
->Listener
->Up
[1];
461 values
[5] = (ALint
)Context
->Listener
->Up
[2];
462 UnlockContext(Context
);
466 al_throwerr(Context
, AL_INVALID_ENUM
);
471 ALCcontext_DecRef(Context
);