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
= GetContextSuspended();
39 pContext
->Listener
.Gain
= flValue
;
41 alSetError(AL_INVALID_VALUE
);
44 case AL_METERS_PER_UNIT
:
46 pContext
->Listener
.MetersPerUnit
= flValue
;
48 alSetError(AL_INVALID_VALUE
);
52 alSetError(AL_INVALID_ENUM
);
56 ProcessContext(pContext
);
60 ALAPI ALvoid ALAPIENTRY
alListener3f(ALenum eParam
, ALfloat flValue1
, ALfloat flValue2
, ALfloat flValue3
)
64 pContext
= GetContextSuspended();
70 pContext
->Listener
.Position
[0] = flValue1
;
71 pContext
->Listener
.Position
[1] = flValue2
;
72 pContext
->Listener
.Position
[2] = flValue3
;
76 pContext
->Listener
.Velocity
[0] = flValue1
;
77 pContext
->Listener
.Velocity
[1] = flValue2
;
78 pContext
->Listener
.Velocity
[2] = flValue3
;
82 alSetError(AL_INVALID_ENUM
);
86 ProcessContext(pContext
);
90 ALAPI ALvoid ALAPIENTRY
alListenerfv(ALenum eParam
, const ALfloat
*pflValues
)
94 pContext
= GetContextSuspended();
102 if(pflValues
[0] >= 0.0f
)
103 pContext
->Listener
.Gain
= pflValues
[0];
105 alSetError(AL_INVALID_VALUE
);
108 case AL_METERS_PER_UNIT
:
109 if(pflValues
[0] > 0.0f
)
110 pContext
->Listener
.MetersPerUnit
= pflValues
[0];
112 alSetError(AL_INVALID_VALUE
);
116 pContext
->Listener
.Position
[0] = pflValues
[0];
117 pContext
->Listener
.Position
[1] = pflValues
[1];
118 pContext
->Listener
.Position
[2] = pflValues
[2];
122 pContext
->Listener
.Velocity
[0] = pflValues
[0];
123 pContext
->Listener
.Velocity
[1] = pflValues
[1];
124 pContext
->Listener
.Velocity
[2] = pflValues
[2];
129 pContext
->Listener
.Forward
[0] = pflValues
[0];
130 pContext
->Listener
.Forward
[1] = pflValues
[1];
131 pContext
->Listener
.Forward
[2] = pflValues
[2];
132 pContext
->Listener
.Up
[0] = pflValues
[3];
133 pContext
->Listener
.Up
[1] = pflValues
[4];
134 pContext
->Listener
.Up
[2] = pflValues
[5];
138 alSetError(AL_INVALID_ENUM
);
143 alSetError(AL_INVALID_VALUE
);
145 ProcessContext(pContext
);
149 ALAPI ALvoid ALAPIENTRY
alListeneri(ALenum eParam
, ALint lValue
)
151 ALCcontext
*pContext
;
155 pContext
= GetContextSuspended();
156 if(!pContext
) return;
161 alSetError(AL_INVALID_ENUM
);
165 ProcessContext(pContext
);
169 ALAPI
void ALAPIENTRY
alListener3i(ALenum eParam
, ALint lValue1
, ALint lValue2
, ALint lValue3
)
171 ALCcontext
*pContext
;
173 pContext
= GetContextSuspended();
174 if(!pContext
) return;
180 alListener3f(eParam
, (ALfloat
)lValue1
, (ALfloat
)lValue2
, (ALfloat
)lValue3
);
184 alSetError(AL_INVALID_ENUM
);
188 ProcessContext(pContext
);
192 ALAPI
void ALAPIENTRY
alListeneriv( ALenum eParam
, const ALint
* plValues
)
194 ALCcontext
*pContext
;
197 pContext
= GetContextSuspended();
198 if(!pContext
) return;
206 flValues
[0] = (ALfloat
)plValues
[0];
207 flValues
[1] = (ALfloat
)plValues
[1];
208 flValues
[2] = (ALfloat
)plValues
[2];
209 alListenerfv(eParam
, flValues
);
213 flValues
[0] = (ALfloat
)plValues
[0];
214 flValues
[1] = (ALfloat
)plValues
[1];
215 flValues
[2] = (ALfloat
)plValues
[2];
216 flValues
[3] = (ALfloat
)plValues
[3];
217 flValues
[4] = (ALfloat
)plValues
[4];
218 flValues
[5] = (ALfloat
)plValues
[5];
219 alListenerfv(eParam
, flValues
);
223 alSetError(AL_INVALID_ENUM
);
228 alSetError(AL_INVALID_VALUE
);
230 ProcessContext(pContext
);
234 ALAPI ALvoid ALAPIENTRY
alGetListenerf(ALenum eParam
, ALfloat
*pflValue
)
236 ALCcontext
*pContext
;
238 pContext
= GetContextSuspended();
239 if(!pContext
) return;
246 *pflValue
= pContext
->Listener
.Gain
;
249 case AL_METERS_PER_UNIT
:
250 *pflValue
= pContext
->Listener
.MetersPerUnit
;
254 alSetError(AL_INVALID_ENUM
);
259 alSetError(AL_INVALID_VALUE
);
261 ProcessContext(pContext
);
265 ALAPI ALvoid ALAPIENTRY
alGetListener3f(ALenum eParam
, ALfloat
*pflValue1
, ALfloat
*pflValue2
, ALfloat
*pflValue3
)
267 ALCcontext
*pContext
;
269 pContext
= GetContextSuspended();
270 if(!pContext
) return;
272 if(pflValue1
&& pflValue2
&& pflValue3
)
277 *pflValue1
= pContext
->Listener
.Position
[0];
278 *pflValue2
= pContext
->Listener
.Position
[1];
279 *pflValue3
= pContext
->Listener
.Position
[2];
283 *pflValue1
= pContext
->Listener
.Velocity
[0];
284 *pflValue2
= pContext
->Listener
.Velocity
[1];
285 *pflValue3
= pContext
->Listener
.Velocity
[2];
289 alSetError(AL_INVALID_ENUM
);
294 alSetError(AL_INVALID_VALUE
);
296 ProcessContext(pContext
);
300 ALAPI ALvoid ALAPIENTRY
alGetListenerfv(ALenum eParam
, ALfloat
*pflValues
)
302 ALCcontext
*pContext
;
304 pContext
= GetContextSuspended();
305 if(!pContext
) return;
312 pflValues
[0] = pContext
->Listener
.Gain
;
315 case AL_METERS_PER_UNIT
:
316 pflValues
[0] = pContext
->Listener
.MetersPerUnit
;
320 pflValues
[0] = pContext
->Listener
.Position
[0];
321 pflValues
[1] = pContext
->Listener
.Position
[1];
322 pflValues
[2] = pContext
->Listener
.Position
[2];
326 pflValues
[0] = pContext
->Listener
.Velocity
[0];
327 pflValues
[1] = pContext
->Listener
.Velocity
[1];
328 pflValues
[2] = pContext
->Listener
.Velocity
[2];
333 pflValues
[0] = pContext
->Listener
.Forward
[0];
334 pflValues
[1] = pContext
->Listener
.Forward
[1];
335 pflValues
[2] = pContext
->Listener
.Forward
[2];
336 pflValues
[3] = pContext
->Listener
.Up
[0];
337 pflValues
[4] = pContext
->Listener
.Up
[1];
338 pflValues
[5] = pContext
->Listener
.Up
[2];
342 alSetError(AL_INVALID_ENUM
);
347 alSetError(AL_INVALID_VALUE
);
349 ProcessContext(pContext
);
353 ALAPI ALvoid ALAPIENTRY
alGetListeneri(ALenum eParam
, ALint
*plValue
)
355 ALCcontext
*pContext
;
357 pContext
= GetContextSuspended();
358 if(!pContext
) return;
365 alSetError(AL_INVALID_ENUM
);
370 alSetError(AL_INVALID_VALUE
);
372 ProcessContext(pContext
);
376 ALAPI
void ALAPIENTRY
alGetListener3i(ALenum eParam
, ALint
*plValue1
, ALint
*plValue2
, ALint
*plValue3
)
378 ALCcontext
*pContext
;
380 pContext
= GetContextSuspended();
381 if(!pContext
) return;
383 if(plValue1
&& plValue2
&& plValue3
)
388 *plValue1
= (ALint
)pContext
->Listener
.Position
[0];
389 *plValue2
= (ALint
)pContext
->Listener
.Position
[1];
390 *plValue3
= (ALint
)pContext
->Listener
.Position
[2];
394 *plValue1
= (ALint
)pContext
->Listener
.Velocity
[0];
395 *plValue2
= (ALint
)pContext
->Listener
.Velocity
[1];
396 *plValue3
= (ALint
)pContext
->Listener
.Velocity
[2];
400 alSetError(AL_INVALID_ENUM
);
405 alSetError(AL_INVALID_VALUE
);
407 ProcessContext(pContext
);
411 ALAPI
void ALAPIENTRY
alGetListeneriv(ALenum eParam
, ALint
* plValues
)
413 ALCcontext
*pContext
;
415 pContext
= GetContextSuspended();
416 if(!pContext
) return;
423 plValues
[0] = (ALint
)pContext
->Listener
.Position
[0];
424 plValues
[1] = (ALint
)pContext
->Listener
.Position
[1];
425 plValues
[2] = (ALint
)pContext
->Listener
.Position
[2];
429 plValues
[0] = (ALint
)pContext
->Listener
.Velocity
[0];
430 plValues
[1] = (ALint
)pContext
->Listener
.Velocity
[1];
431 plValues
[2] = (ALint
)pContext
->Listener
.Velocity
[2];
436 plValues
[0] = (ALint
)pContext
->Listener
.Forward
[0];
437 plValues
[1] = (ALint
)pContext
->Listener
.Forward
[1];
438 plValues
[2] = (ALint
)pContext
->Listener
.Forward
[2];
439 plValues
[3] = (ALint
)pContext
->Listener
.Up
[0];
440 plValues
[4] = (ALint
)pContext
->Listener
.Up
[1];
441 plValues
[5] = (ALint
)pContext
->Listener
.Up
[2];
445 alSetError(AL_INVALID_ENUM
);
450 alSetError(AL_INVALID_VALUE
);
452 ProcessContext(pContext
);