zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
alListener.c
Go to the documentation of this file.
1 
21 #include "config.h"
22 
23 #include "alMain.h"
24 #include "AL/alc.h"
25 #include "alError.h"
26 #include "alListener.h"
27 #include "alSource.h"
28 
30 {
31  ALCcontext *Context;
32 
33  Context = GetContextRef();
34  if(!Context) return;
35 
36  al_try
37  {
38  switch(param)
39  {
40  case AL_GAIN:
41  CHECK_VALUE(Context, value >= 0.0f && isfinite(value));
42 
43  Context->Listener->Gain = value;
44  Context->UpdateSources = AL_TRUE;
45  break;
46 
47  case AL_METERS_PER_UNIT:
48  CHECK_VALUE(Context, value >= 0.0f && isfinite(value));
49 
50  Context->Listener->MetersPerUnit = value;
51  Context->UpdateSources = AL_TRUE;
52  break;
53 
54  default:
55  al_throwerr(Context, AL_INVALID_ENUM);
56  }
57  }
58  al_endtry;
59 
60  ALCcontext_DecRef(Context);
61 }
62 
63 
65 {
66  ALCcontext *Context;
67 
68  Context = GetContextRef();
69  if(!Context) return;
70 
71  al_try
72  {
73  switch(param)
74  {
75  case AL_POSITION:
76  CHECK_VALUE(Context, isfinite(value1) && isfinite(value2) && isfinite(value3));
77 
78  LockContext(Context);
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);
84  break;
85 
86  case AL_VELOCITY:
87  CHECK_VALUE(Context, isfinite(value1) && isfinite(value2) && isfinite(value3));
88 
89  LockContext(Context);
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);
95  break;
96 
97  default:
98  al_throwerr(Context, AL_INVALID_ENUM);
99  }
100  }
101  al_endtry;
102 
103  ALCcontext_DecRef(Context);
104 }
105 
106 
108 {
109  ALCcontext *Context;
110 
111  if(values)
112  {
113  switch(param)
114  {
115  case AL_GAIN:
116  case AL_METERS_PER_UNIT:
117  alListenerf(param, values[0]);
118  return;
119 
120  case AL_POSITION:
121  case AL_VELOCITY:
122  alListener3f(param, values[0], values[1], values[2]);
123  return;
124  }
125  }
126 
127  Context = GetContextRef();
128  if(!Context) return;
129 
130  al_try
131  {
132  CHECK_VALUE(Context, values);
133  switch(param)
134  {
135  case AL_ORIENTATION:
136  CHECK_VALUE(Context, isfinite(values[0]) && isfinite(values[1]) &&
137  isfinite(values[2]) && isfinite(values[3]) &&
138  isfinite(values[4]) && isfinite(values[5]));
139 
140  LockContext(Context);
141  /* AT then UP */
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);
150  break;
151 
152  default:
153  al_throwerr(Context, AL_INVALID_ENUM);
154  }
155  }
156  al_endtry;
157 
158  ALCcontext_DecRef(Context);
159 }
160 
161 
163 {
164  ALCcontext *Context;
165 
166  (void)value;
167 
168  Context = GetContextRef();
169  if(!Context) return;
170 
171  al_try
172  {
173  switch(param)
174  {
175  default:
176  al_throwerr(Context, AL_INVALID_ENUM);
177  }
178  }
179  al_endtry;
180 
181  ALCcontext_DecRef(Context);
182 }
183 
184 
186 {
187  ALCcontext *Context;
188 
189  switch(param)
190  {
191  case AL_POSITION:
192  case AL_VELOCITY:
193  alListener3f(param, (ALfloat)value1, (ALfloat)value2, (ALfloat)value3);
194  return;
195  }
196 
197  Context = GetContextRef();
198  if(!Context) return;
199 
200  al_try
201  {
202  switch(param)
203  {
204  default:
205  al_throwerr(Context, AL_INVALID_ENUM);
206  }
207  }
208  al_endtry;
209 
210  ALCcontext_DecRef(Context);
211 }
212 
213 
215 {
216  ALCcontext *Context;
217 
218  if(values)
219  {
220  ALfloat fvals[6];
221  switch(param)
222  {
223  case AL_POSITION:
224  case AL_VELOCITY:
225  alListener3f(param, (ALfloat)values[0], (ALfloat)values[1], (ALfloat)values[2]);
226  return;
227 
228  case AL_ORIENTATION:
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);
236  return;
237  }
238  }
239 
240  Context = GetContextRef();
241  if(!Context) return;
242 
243  al_try
244  {
245  CHECK_VALUE(Context, values);
246  switch(param)
247  {
248  default:
249  al_throwerr(Context, AL_INVALID_ENUM);
250  }
251  }
252  al_endtry;
253 
254  ALCcontext_DecRef(Context);
255 }
256 
257 
259 {
260  ALCcontext *Context;
261 
262  Context = GetContextRef();
263  if(!Context) return;
264 
265  al_try
266  {
267  CHECK_VALUE(Context, value);
268  switch(param)
269  {
270  case AL_GAIN:
271  *value = Context->Listener->Gain;
272  break;
273 
274  case AL_METERS_PER_UNIT:
275  *value = Context->Listener->MetersPerUnit;
276  break;
277 
278  default:
279  al_throwerr(Context, AL_INVALID_ENUM);
280  }
281  }
282  al_endtry;
283 
284  ALCcontext_DecRef(Context);
285 }
286 
287 
289 {
290  ALCcontext *Context;
291 
292  Context = GetContextRef();
293  if(!Context) return;
294 
295  al_try
296  {
297  CHECK_VALUE(Context, value1 && value2 && value3);
298  switch(param)
299  {
300  case AL_POSITION:
301  LockContext(Context);
302  *value1 = Context->Listener->Position[0];
303  *value2 = Context->Listener->Position[1];
304  *value3 = Context->Listener->Position[2];
305  UnlockContext(Context);
306  break;
307 
308  case AL_VELOCITY:
309  LockContext(Context);
310  *value1 = Context->Listener->Velocity[0];
311  *value2 = Context->Listener->Velocity[1];
312  *value3 = Context->Listener->Velocity[2];
313  UnlockContext(Context);
314  break;
315 
316  default:
317  al_throwerr(Context, AL_INVALID_ENUM);
318  }
319  }
320  al_endtry;
321 
322  ALCcontext_DecRef(Context);
323 }
324 
325 
327 {
328  ALCcontext *Context;
329 
330  switch(param)
331  {
332  case AL_GAIN:
333  case AL_METERS_PER_UNIT:
334  alGetListenerf(param, values);
335  return;
336 
337  case AL_POSITION:
338  case AL_VELOCITY:
339  alGetListener3f(param, values+0, values+1, values+2);
340  return;
341  }
342 
343  Context = GetContextRef();
344  if(!Context) return;
345 
346  al_try
347  {
348  CHECK_VALUE(Context, values);
349  switch(param)
350  {
351  case AL_ORIENTATION:
352  LockContext(Context);
353  // AT then UP
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);
361  break;
362 
363  default:
364  al_throwerr(Context, AL_INVALID_ENUM);
365  }
366  }
367  al_endtry;
368 
369  ALCcontext_DecRef(Context);
370 }
371 
372 
374 {
375  ALCcontext *Context;
376 
377  Context = GetContextRef();
378  if(!Context) return;
379 
380  al_try
381  {
382  CHECK_VALUE(Context, value);
383  switch(param)
384  {
385  default:
386  al_throwerr(Context, AL_INVALID_ENUM);
387  }
388  }
389  al_endtry;
390 
391  ALCcontext_DecRef(Context);
392 }
393 
394 
395 AL_API void AL_APIENTRY alGetListener3i(ALenum param, ALint *value1, ALint *value2, ALint *value3)
396 {
397  ALCcontext *Context;
398 
399  Context = GetContextRef();
400  if(!Context) return;
401 
402  al_try
403  {
404  CHECK_VALUE(Context, value1 && value2 && value3);
405  switch (param)
406  {
407  case AL_POSITION:
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);
413  break;
414 
415  case AL_VELOCITY:
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);
421  break;
422 
423  default:
424  al_throwerr(Context, AL_INVALID_ENUM);
425  }
426  }
427  al_endtry;
428 
429  ALCcontext_DecRef(Context);
430 }
431 
432 
434 {
435  ALCcontext *Context;
436 
437  switch(param)
438  {
439  case AL_POSITION:
440  case AL_VELOCITY:
441  alGetListener3i(param, values+0, values+1, values+2);
442  return;
443  }
444 
445  Context = GetContextRef();
446  if(!Context) return;
447 
448  al_try
449  {
450  CHECK_VALUE(Context, values);
451  switch(param)
452  {
453  case AL_ORIENTATION:
454  LockContext(Context);
455  // AT then UP
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);
463  break;
464 
465  default:
466  al_throwerr(Context, AL_INVALID_ENUM);
467  }
468  }
469  al_endtry;
470 
471  ALCcontext_DecRef(Context);
472 }
#define AL_APIENTRY
Definition: al.h:21
AL_API void AL_APIENTRY alGetListeneriv(ALenum param, ALint *values)
Definition: alListener.c:433
volatile ALenum UpdateSources
Definition: alMain.h:686
struct ALlistener * Listener
Definition: alMain.h:679
#define AL_METERS_PER_UNIT
Definition: efx.h:20
void ALvoid
Definition: al.h:74
GLenum GLint param
Definition: gl2ext.h:1491
GLvoid **typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
Definition: glew.h:1824
#define CHECK_VALUE(ctx, cond)
Definition: alMain.h:875
#define AL_TRUE
Definition: al.h:86
GLclampf f
Definition: glew.h:3390
volatile ALfloat MetersPerUnit
Definition: alListener.h:16
AL_API void AL_APIENTRY alGetListeneri(ALenum param, ALint *value)
Definition: alListener.c:373
#define al_throwerr(ctx, err)
Definition: alMain.h:866
#define al_try
Definition: alMain.h:838
int ALint
Definition: al.h:56
#define al_endtry
Definition: alMain.h:853
ALCcontext * GetContextRef(void)
Definition: ALc.c:1999
AL_API void AL_APIENTRY alListeneri(ALenum param, ALint value)
Definition: alListener.c:162
AL_API void AL_APIENTRY alListener3i(ALenum param, ALint value1, ALint value2, ALint value3)
Definition: alListener.c:185
float ALfloat
Definition: al.h:68
AL_API void AL_APIENTRY alGetListener3i(ALenum param, ALint *value1, ALint *value2, ALint *value3)
Definition: alListener.c:395
volatile ALfloat Position[3]
Definition: alListener.h:11
#define AL_POSITION
Definition: al.h:144
AL_API void AL_APIENTRY alListenerf(ALenum param, ALfloat value)
Definition: alListener.c:29
int ALenum
Definition: al.h:65
volatile ALfloat Up[3]
Definition: alListener.h:14
#define AL_API
Definition: al.h:14
AL_API void AL_APIENTRY alListeneriv(ALenum param, const ALint *values)
Definition: alListener.c:214
void ALCcontext_DecRef(ALCcontext *context)
Definition: ALc.c:1949
volatile ALfloat Velocity[3]
Definition: alListener.h:12
EGLSurface EGLint void ** value
Definition: eglext.h:301
volatile ALfloat Forward[3]
Definition: alListener.h:13
AL_API void AL_APIENTRY alGetListener3f(ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3)
Definition: alListener.c:288
volatile ALfloat Gain
Definition: alListener.h:15
AL_API void AL_APIENTRY alGetListenerf(ALenum param, ALfloat *value)
Definition: alListener.c:258
AL_API void AL_APIENTRY alListener3f(ALenum param, ALfloat value1, ALfloat value2, ALfloat value3)
Definition: alListener.c:64
#define AL_ORIENTATION
Definition: al.h:228
static __inline void LockContext(ALCcontext *context)
Definition: alMain.h:728
#define AL_GAIN
Definition: al.h:196
static __inline void UnlockContext(ALCcontext *context)
Definition: alMain.h:730
AL_API void AL_APIENTRY alListenerfv(ALenum param, const ALfloat *values)
Definition: alListener.c:107
#define AL_INVALID_ENUM
Definition: al.h:370
GLint GLsizei const GLuint64 * values
Definition: glew.h:3473
#define AL_VELOCITY
Definition: al.h:163
AL_API void AL_APIENTRY alGetListenerfv(ALenum param, ALfloat *values)
Definition: alListener.c:326