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"
28 ALAPI ALvoid ALAPIENTRY
alListenerf(ALenum eParam
, ALfloat flValue
)
32 pContext
= alcGetCurrentContext();
35 SuspendContext(pContext
);
41 pContext
->Listener
.Gain
= flValue
;
43 alSetError(AL_INVALID_VALUE
);
46 case AL_METERS_PER_UNIT
:
48 pContext
->Listener
.MetersPerUnit
= flValue
;
50 alSetError(AL_INVALID_VALUE
);
54 alSetError(AL_INVALID_ENUM
);
58 ProcessContext(pContext
);
61 alSetError(AL_INVALID_OPERATION
);
67 ALAPI ALvoid ALAPIENTRY
alListener3f(ALenum eParam
, ALfloat flValue1
, ALfloat flValue2
, ALfloat flValue3
)
71 pContext
= alcGetCurrentContext();
74 SuspendContext(pContext
);
79 pContext
->Listener
.Position
[0] = flValue1
;
80 pContext
->Listener
.Position
[1] = flValue2
;
81 pContext
->Listener
.Position
[2] = flValue3
;
85 pContext
->Listener
.Velocity
[0] = flValue1
;
86 pContext
->Listener
.Velocity
[1] = flValue2
;
87 pContext
->Listener
.Velocity
[2] = flValue3
;
91 alSetError(AL_INVALID_ENUM
);
95 ProcessContext(pContext
);
98 alSetError(AL_INVALID_OPERATION
);
104 ALAPI ALvoid ALAPIENTRY
alListenerfv(ALenum eParam
, const ALfloat
*pflValues
)
106 ALCcontext
*pContext
;
108 pContext
= alcGetCurrentContext();
111 SuspendContext(pContext
);
118 if (pflValues
[0] >= 0.0f
)
119 pContext
->Listener
.Gain
= pflValues
[0];
121 alSetError(AL_INVALID_VALUE
);
124 case AL_METERS_PER_UNIT
:
125 if (pflValues
[0] > 0.0f
)
126 pContext
->Listener
.MetersPerUnit
= pflValues
[0];
128 alSetError(AL_INVALID_VALUE
);
132 pContext
->Listener
.Position
[0] = pflValues
[0];
133 pContext
->Listener
.Position
[1] = pflValues
[1];
134 pContext
->Listener
.Position
[2] = pflValues
[2];
138 pContext
->Listener
.Velocity
[0] = pflValues
[0];
139 pContext
->Listener
.Velocity
[1] = pflValues
[1];
140 pContext
->Listener
.Velocity
[2] = pflValues
[2];
145 pContext
->Listener
.Forward
[0] = pflValues
[0];
146 pContext
->Listener
.Forward
[1] = pflValues
[1];
147 pContext
->Listener
.Forward
[2] = pflValues
[2];
148 pContext
->Listener
.Up
[0] = pflValues
[3];
149 pContext
->Listener
.Up
[1] = pflValues
[4];
150 pContext
->Listener
.Up
[2] = pflValues
[5];
154 alSetError(AL_INVALID_ENUM
);
159 alSetError(AL_INVALID_VALUE
);
161 ProcessContext(pContext
);
164 alSetError(AL_INVALID_OPERATION
);
170 ALAPI ALvoid ALAPIENTRY
alListeneri(ALenum eParam
, ALint lValue
)
172 ALCcontext
*pContext
;
176 pContext
= alcGetCurrentContext();
179 SuspendContext(pContext
);
184 alSetError(AL_INVALID_ENUM
);
188 ProcessContext(pContext
);
191 alSetError(AL_INVALID_OPERATION
);
197 ALAPI
void ALAPIENTRY
alListener3i(ALenum eParam
, ALint lValue1
, ALint lValue2
, ALint lValue3
)
199 ALCcontext
*pContext
;
201 pContext
= alcGetCurrentContext();
204 SuspendContext(pContext
);
210 alListener3f(eParam
, (ALfloat
)lValue1
, (ALfloat
)lValue2
, (ALfloat
)lValue3
);
214 alSetError(AL_INVALID_ENUM
);
218 ProcessContext(pContext
);
221 alSetError(AL_INVALID_OPERATION
);
227 ALAPI
void ALAPIENTRY
alListeneriv( ALenum eParam
, const ALint
* plValues
)
229 ALCcontext
*pContext
;
232 pContext
= alcGetCurrentContext();
235 SuspendContext(pContext
);
243 flValues
[0] = (ALfloat
)plValues
[0];
244 flValues
[1] = (ALfloat
)plValues
[1];
245 flValues
[2] = (ALfloat
)plValues
[2];
246 alListenerfv(eParam
, flValues
);
250 flValues
[0] = (ALfloat
)plValues
[0];
251 flValues
[1] = (ALfloat
)plValues
[1];
252 flValues
[2] = (ALfloat
)plValues
[2];
253 flValues
[3] = (ALfloat
)plValues
[3];
254 flValues
[4] = (ALfloat
)plValues
[4];
255 flValues
[5] = (ALfloat
)plValues
[5];
256 alListenerfv(eParam
, flValues
);
260 alSetError(AL_INVALID_ENUM
);
265 alSetError(AL_INVALID_VALUE
);
267 ProcessContext(pContext
);
270 alSetError(AL_INVALID_OPERATION
);
276 ALAPI ALvoid ALAPIENTRY
alGetListenerf(ALenum eParam
, ALfloat
*pflValue
)
278 ALCcontext
*pContext
;
280 pContext
= alcGetCurrentContext();
283 SuspendContext(pContext
);
290 *pflValue
= pContext
->Listener
.Gain
;
293 case AL_METERS_PER_UNIT
:
294 *pflValue
= pContext
->Listener
.MetersPerUnit
;
298 alSetError(AL_INVALID_ENUM
);
303 alSetError(AL_INVALID_VALUE
);
305 ProcessContext(pContext
);
308 alSetError(AL_INVALID_OPERATION
);
314 ALAPI ALvoid ALAPIENTRY
alGetListener3f(ALenum eParam
, ALfloat
*pflValue1
, ALfloat
*pflValue2
, ALfloat
*pflValue3
)
316 ALCcontext
*pContext
;
318 pContext
= alcGetCurrentContext();
321 SuspendContext(pContext
);
323 if ((pflValue1
) && (pflValue2
) && (pflValue3
))
328 *pflValue1
= pContext
->Listener
.Position
[0];
329 *pflValue2
= pContext
->Listener
.Position
[1];
330 *pflValue3
= pContext
->Listener
.Position
[2];
334 *pflValue1
= pContext
->Listener
.Velocity
[0];
335 *pflValue2
= pContext
->Listener
.Velocity
[1];
336 *pflValue3
= pContext
->Listener
.Velocity
[2];
340 alSetError(AL_INVALID_ENUM
);
345 alSetError(AL_INVALID_VALUE
);
347 ProcessContext(pContext
);
350 alSetError(AL_INVALID_OPERATION
);
356 ALAPI ALvoid ALAPIENTRY
alGetListenerfv(ALenum eParam
, ALfloat
*pflValues
)
358 ALCcontext
*pContext
;
360 pContext
= alcGetCurrentContext();
363 SuspendContext(pContext
);
370 pflValues
[0] = pContext
->Listener
.Gain
;
373 case AL_METERS_PER_UNIT
:
374 pflValues
[0] = pContext
->Listener
.MetersPerUnit
;
378 pflValues
[0] = pContext
->Listener
.Position
[0];
379 pflValues
[1] = pContext
->Listener
.Position
[1];
380 pflValues
[2] = pContext
->Listener
.Position
[2];
384 pflValues
[0] = pContext
->Listener
.Velocity
[0];
385 pflValues
[1] = pContext
->Listener
.Velocity
[1];
386 pflValues
[2] = pContext
->Listener
.Velocity
[2];
391 pflValues
[0] = pContext
->Listener
.Forward
[0];
392 pflValues
[1] = pContext
->Listener
.Forward
[1];
393 pflValues
[2] = pContext
->Listener
.Forward
[2];
394 pflValues
[3] = pContext
->Listener
.Up
[0];
395 pflValues
[4] = pContext
->Listener
.Up
[1];
396 pflValues
[5] = pContext
->Listener
.Up
[2];
400 alSetError(AL_INVALID_ENUM
);
405 alSetError(AL_INVALID_VALUE
);
407 ProcessContext(pContext
);
410 alSetError(AL_INVALID_OPERATION
);
416 ALAPI ALvoid ALAPIENTRY
alGetListeneri(ALenum eParam
, ALint
*plValue
)
418 ALCcontext
*pContext
;
420 pContext
= alcGetCurrentContext();
423 SuspendContext(pContext
);
430 alSetError(AL_INVALID_ENUM
);
435 alSetError(AL_INVALID_VALUE
);
437 ProcessContext(pContext
);
440 alSetError(AL_INVALID_OPERATION
);
446 ALAPI
void ALAPIENTRY
alGetListener3i(ALenum eParam
, ALint
*plValue1
, ALint
*plValue2
, ALint
*plValue3
)
448 ALCcontext
*pContext
;
450 pContext
= alcGetCurrentContext();
453 SuspendContext(pContext
);
455 if ((plValue1
) && (plValue2
) && (plValue3
))
460 *plValue1
= (ALint
)pContext
->Listener
.Position
[0];
461 *plValue2
= (ALint
)pContext
->Listener
.Position
[1];
462 *plValue3
= (ALint
)pContext
->Listener
.Position
[2];
466 *plValue1
= (ALint
)pContext
->Listener
.Velocity
[0];
467 *plValue2
= (ALint
)pContext
->Listener
.Velocity
[1];
468 *plValue3
= (ALint
)pContext
->Listener
.Velocity
[2];
472 alSetError(AL_INVALID_ENUM
);
477 alSetError(AL_INVALID_VALUE
);
479 ProcessContext(pContext
);
482 alSetError(AL_INVALID_OPERATION
);
488 ALAPI
void ALAPIENTRY
alGetListeneriv(ALenum eParam
, ALint
* plValues
)
490 ALCcontext
*pContext
;
492 pContext
= alcGetCurrentContext();
495 SuspendContext(pContext
);
502 plValues
[0] = (ALint
)pContext
->Listener
.Position
[0];
503 plValues
[1] = (ALint
)pContext
->Listener
.Position
[1];
504 plValues
[2] = (ALint
)pContext
->Listener
.Position
[2];
508 plValues
[0] = (ALint
)pContext
->Listener
.Velocity
[0];
509 plValues
[1] = (ALint
)pContext
->Listener
.Velocity
[1];
510 plValues
[2] = (ALint
)pContext
->Listener
.Velocity
[2];
515 plValues
[0] = (ALint
)pContext
->Listener
.Forward
[0];
516 plValues
[1] = (ALint
)pContext
->Listener
.Forward
[1];
517 plValues
[2] = (ALint
)pContext
->Listener
.Forward
[2];
518 plValues
[3] = (ALint
)pContext
->Listener
.Up
[0];
519 plValues
[4] = (ALint
)pContext
->Listener
.Up
[1];
520 plValues
[5] = (ALint
)pContext
->Listener
.Up
[2];
524 alSetError(AL_INVALID_ENUM
);
529 alSetError(AL_INVALID_VALUE
);
531 ProcessContext(pContext
);
534 alSetError(AL_INVALID_OPERATION
);