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 eParam
, ALfloat flValue
)
32 ALboolean updateAll
= AL_FALSE
;
34 pContext
= GetContextSuspended();
42 pContext
->Listener
.Gain
= flValue
;
46 alSetError(pContext
, AL_INVALID_VALUE
);
49 case AL_METERS_PER_UNIT
:
52 pContext
->Listener
.MetersPerUnit
= flValue
;
56 alSetError(pContext
, AL_INVALID_VALUE
);
60 alSetError(pContext
, AL_INVALID_ENUM
);
64 // Force updating the sources for these parameters, since even head-
65 // relative sources are affected
69 for(pos
= 0;pos
< pContext
->SourceMap
.size
;pos
++)
71 ALsource
*source
= pContext
->SourceMap
.array
[pos
].value
;
72 source
->NeedsUpdate
= AL_TRUE
;
76 ProcessContext(pContext
);
80 AL_API ALvoid AL_APIENTRY
alListener3f(ALenum eParam
, ALfloat flValue1
, ALfloat flValue2
, ALfloat flValue3
)
83 ALboolean updateWorld
= AL_FALSE
;
85 pContext
= GetContextSuspended();
91 pContext
->Listener
.Position
[0] = flValue1
;
92 pContext
->Listener
.Position
[1] = flValue2
;
93 pContext
->Listener
.Position
[2] = flValue3
;
94 updateWorld
= AL_TRUE
;
98 pContext
->Listener
.Velocity
[0] = flValue1
;
99 pContext
->Listener
.Velocity
[1] = flValue2
;
100 pContext
->Listener
.Velocity
[2] = flValue3
;
101 updateWorld
= AL_TRUE
;
105 alSetError(pContext
, AL_INVALID_ENUM
);
112 for(pos
= 0;pos
< pContext
->SourceMap
.size
;pos
++)
114 ALsource
*source
= pContext
->SourceMap
.array
[pos
].value
;
115 if(!source
->bHeadRelative
)
116 source
->NeedsUpdate
= AL_TRUE
;
120 ProcessContext(pContext
);
124 AL_API ALvoid AL_APIENTRY
alListenerfv(ALenum eParam
, const ALfloat
*pflValues
)
126 ALCcontext
*pContext
;
127 ALboolean updateWorld
= AL_FALSE
;
129 pContext
= GetContextSuspended();
130 if(!pContext
) return;
137 case AL_METERS_PER_UNIT
:
138 alListenerf(eParam
, pflValues
[0]);
143 alListener3f(eParam
, pflValues
[0], pflValues
[1], pflValues
[2]);
148 pContext
->Listener
.Forward
[0] = pflValues
[0];
149 pContext
->Listener
.Forward
[1] = pflValues
[1];
150 pContext
->Listener
.Forward
[2] = pflValues
[2];
151 pContext
->Listener
.Up
[0] = pflValues
[3];
152 pContext
->Listener
.Up
[1] = pflValues
[4];
153 pContext
->Listener
.Up
[2] = pflValues
[5];
154 updateWorld
= AL_TRUE
;
158 alSetError(pContext
, AL_INVALID_ENUM
);
163 alSetError(pContext
, AL_INVALID_VALUE
);
168 for(pos
= 0;pos
< pContext
->SourceMap
.size
;pos
++)
170 ALsource
*source
= pContext
->SourceMap
.array
[pos
].value
;
171 if(!source
->bHeadRelative
)
172 source
->NeedsUpdate
= AL_TRUE
;
176 ProcessContext(pContext
);
180 AL_API ALvoid AL_APIENTRY
alListeneri(ALenum eParam
, ALint lValue
)
182 ALCcontext
*pContext
;
186 pContext
= GetContextSuspended();
187 if(!pContext
) return;
192 alSetError(pContext
, AL_INVALID_ENUM
);
196 ProcessContext(pContext
);
200 AL_API
void AL_APIENTRY
alListener3i(ALenum eParam
, ALint lValue1
, ALint lValue2
, ALint lValue3
)
202 ALCcontext
*pContext
;
204 pContext
= GetContextSuspended();
205 if(!pContext
) return;
211 alListener3f(eParam
, (ALfloat
)lValue1
, (ALfloat
)lValue2
, (ALfloat
)lValue3
);
215 alSetError(pContext
, AL_INVALID_ENUM
);
219 ProcessContext(pContext
);
223 AL_API
void AL_APIENTRY
alListeneriv( ALenum eParam
, const ALint
* plValues
)
225 ALCcontext
*pContext
;
228 pContext
= GetContextSuspended();
229 if(!pContext
) return;
237 flValues
[0] = (ALfloat
)plValues
[0];
238 flValues
[1] = (ALfloat
)plValues
[1];
239 flValues
[2] = (ALfloat
)plValues
[2];
240 alListenerfv(eParam
, flValues
);
244 flValues
[0] = (ALfloat
)plValues
[0];
245 flValues
[1] = (ALfloat
)plValues
[1];
246 flValues
[2] = (ALfloat
)plValues
[2];
247 flValues
[3] = (ALfloat
)plValues
[3];
248 flValues
[4] = (ALfloat
)plValues
[4];
249 flValues
[5] = (ALfloat
)plValues
[5];
250 alListenerfv(eParam
, flValues
);
254 alSetError(pContext
, AL_INVALID_ENUM
);
259 alSetError(pContext
, AL_INVALID_VALUE
);
261 ProcessContext(pContext
);
265 AL_API ALvoid AL_APIENTRY
alGetListenerf(ALenum eParam
, ALfloat
*pflValue
)
267 ALCcontext
*pContext
;
269 pContext
= GetContextSuspended();
270 if(!pContext
) return;
277 *pflValue
= pContext
->Listener
.Gain
;
280 case AL_METERS_PER_UNIT
:
281 *pflValue
= pContext
->Listener
.MetersPerUnit
;
285 alSetError(pContext
, AL_INVALID_ENUM
);
290 alSetError(pContext
, AL_INVALID_VALUE
);
292 ProcessContext(pContext
);
296 AL_API ALvoid AL_APIENTRY
alGetListener3f(ALenum eParam
, ALfloat
*pflValue1
, ALfloat
*pflValue2
, ALfloat
*pflValue3
)
298 ALCcontext
*pContext
;
300 pContext
= GetContextSuspended();
301 if(!pContext
) return;
303 if(pflValue1
&& pflValue2
&& pflValue3
)
308 *pflValue1
= pContext
->Listener
.Position
[0];
309 *pflValue2
= pContext
->Listener
.Position
[1];
310 *pflValue3
= pContext
->Listener
.Position
[2];
314 *pflValue1
= pContext
->Listener
.Velocity
[0];
315 *pflValue2
= pContext
->Listener
.Velocity
[1];
316 *pflValue3
= pContext
->Listener
.Velocity
[2];
320 alSetError(pContext
, AL_INVALID_ENUM
);
325 alSetError(pContext
, AL_INVALID_VALUE
);
327 ProcessContext(pContext
);
331 AL_API ALvoid AL_APIENTRY
alGetListenerfv(ALenum eParam
, ALfloat
*pflValues
)
333 ALCcontext
*pContext
;
335 pContext
= GetContextSuspended();
336 if(!pContext
) return;
343 pflValues
[0] = pContext
->Listener
.Gain
;
346 case AL_METERS_PER_UNIT
:
347 pflValues
[0] = pContext
->Listener
.MetersPerUnit
;
351 pflValues
[0] = pContext
->Listener
.Position
[0];
352 pflValues
[1] = pContext
->Listener
.Position
[1];
353 pflValues
[2] = pContext
->Listener
.Position
[2];
357 pflValues
[0] = pContext
->Listener
.Velocity
[0];
358 pflValues
[1] = pContext
->Listener
.Velocity
[1];
359 pflValues
[2] = pContext
->Listener
.Velocity
[2];
364 pflValues
[0] = pContext
->Listener
.Forward
[0];
365 pflValues
[1] = pContext
->Listener
.Forward
[1];
366 pflValues
[2] = pContext
->Listener
.Forward
[2];
367 pflValues
[3] = pContext
->Listener
.Up
[0];
368 pflValues
[4] = pContext
->Listener
.Up
[1];
369 pflValues
[5] = pContext
->Listener
.Up
[2];
373 alSetError(pContext
, AL_INVALID_ENUM
);
378 alSetError(pContext
, AL_INVALID_VALUE
);
380 ProcessContext(pContext
);
384 AL_API ALvoid AL_APIENTRY
alGetListeneri(ALenum eParam
, ALint
*plValue
)
386 ALCcontext
*pContext
;
388 pContext
= GetContextSuspended();
389 if(!pContext
) return;
396 alSetError(pContext
, AL_INVALID_ENUM
);
401 alSetError(pContext
, AL_INVALID_VALUE
);
403 ProcessContext(pContext
);
407 AL_API
void AL_APIENTRY
alGetListener3i(ALenum eParam
, ALint
*plValue1
, ALint
*plValue2
, ALint
*plValue3
)
409 ALCcontext
*pContext
;
411 pContext
= GetContextSuspended();
412 if(!pContext
) return;
414 if(plValue1
&& plValue2
&& plValue3
)
419 *plValue1
= (ALint
)pContext
->Listener
.Position
[0];
420 *plValue2
= (ALint
)pContext
->Listener
.Position
[1];
421 *plValue3
= (ALint
)pContext
->Listener
.Position
[2];
425 *plValue1
= (ALint
)pContext
->Listener
.Velocity
[0];
426 *plValue2
= (ALint
)pContext
->Listener
.Velocity
[1];
427 *plValue3
= (ALint
)pContext
->Listener
.Velocity
[2];
431 alSetError(pContext
, AL_INVALID_ENUM
);
436 alSetError(pContext
, AL_INVALID_VALUE
);
438 ProcessContext(pContext
);
442 AL_API
void AL_APIENTRY
alGetListeneriv(ALenum eParam
, ALint
* plValues
)
444 ALCcontext
*pContext
;
446 pContext
= GetContextSuspended();
447 if(!pContext
) return;
454 plValues
[0] = (ALint
)pContext
->Listener
.Position
[0];
455 plValues
[1] = (ALint
)pContext
->Listener
.Position
[1];
456 plValues
[2] = (ALint
)pContext
->Listener
.Position
[2];
460 plValues
[0] = (ALint
)pContext
->Listener
.Velocity
[0];
461 plValues
[1] = (ALint
)pContext
->Listener
.Velocity
[1];
462 plValues
[2] = (ALint
)pContext
->Listener
.Velocity
[2];
467 plValues
[0] = (ALint
)pContext
->Listener
.Forward
[0];
468 plValues
[1] = (ALint
)pContext
->Listener
.Forward
[1];
469 plValues
[2] = (ALint
)pContext
->Listener
.Forward
[2];
470 plValues
[3] = (ALint
)pContext
->Listener
.Up
[0];
471 plValues
[4] = (ALint
)pContext
->Listener
.Up
[1];
472 plValues
[5] = (ALint
)pContext
->Listener
.Up
[2];
476 alSetError(pContext
, AL_INVALID_ENUM
);
481 alSetError(pContext
, AL_INVALID_VALUE
);
483 ProcessContext(pContext
);