annotate OpenAL32/alListener.c @ 6:99df34265b40

disabled the user's ability to select backend since there is only one backend
author Robert McIntyre <rlm@mit.edu>
date Tue, 25 Oct 2011 13:25:47 -0700
parents f9476ff7637e
children
rev   line source
rlm@0 1 /**
rlm@0 2 * OpenAL cross platform audio library
rlm@0 3 * Copyright (C) 1999-2000 by authors.
rlm@0 4 * This library is free software; you can redistribute it and/or
rlm@0 5 * modify it under the terms of the GNU Library General Public
rlm@0 6 * License as published by the Free Software Foundation; either
rlm@0 7 * version 2 of the License, or (at your option) any later version.
rlm@0 8 *
rlm@0 9 * This library is distributed in the hope that it will be useful,
rlm@0 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
rlm@0 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
rlm@0 12 * Library General Public License for more details.
rlm@0 13 *
rlm@0 14 * You should have received a copy of the GNU Library General Public
rlm@0 15 * License along with this library; if not, write to the
rlm@0 16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
rlm@0 17 * Boston, MA 02111-1307, USA.
rlm@0 18 * Or go to http://www.gnu.org/copyleft/lgpl.html
rlm@0 19 */
rlm@0 20
rlm@0 21 #include "config.h"
rlm@0 22
rlm@0 23 #include "alMain.h"
rlm@0 24 #include "AL/alc.h"
rlm@0 25 #include "alError.h"
rlm@0 26 #include "alListener.h"
rlm@0 27 #include "alSource.h"
rlm@0 28
rlm@0 29 AL_API ALvoid AL_APIENTRY alListenerf(ALenum eParam, ALfloat flValue)
rlm@0 30 {
rlm@0 31 ALCcontext *pContext;
rlm@0 32
rlm@0 33 pContext = GetLockedContext();
rlm@0 34 if(!pContext) return;
rlm@0 35
rlm@0 36 switch(eParam)
rlm@0 37 {
rlm@0 38 case AL_GAIN:
rlm@0 39 if(flValue >= 0.0f && isfinite(flValue))
rlm@0 40 {
rlm@0 41 pContext->Listener.Gain = flValue;
rlm@0 42 pContext->UpdateSources = AL_TRUE;
rlm@0 43 }
rlm@0 44 else
rlm@0 45 alSetError(pContext, AL_INVALID_VALUE);
rlm@0 46 break;
rlm@0 47
rlm@0 48 case AL_METERS_PER_UNIT:
rlm@0 49 if(flValue > 0.0f && isfinite(flValue))
rlm@0 50 {
rlm@0 51 pContext->Listener.MetersPerUnit = flValue;
rlm@0 52 pContext->UpdateSources = AL_TRUE;
rlm@0 53 }
rlm@0 54 else
rlm@0 55 alSetError(pContext, AL_INVALID_VALUE);
rlm@0 56 break;
rlm@0 57
rlm@0 58 default:
rlm@0 59 alSetError(pContext, AL_INVALID_ENUM);
rlm@0 60 break;
rlm@0 61 }
rlm@0 62
rlm@0 63 UnlockContext(pContext);
rlm@0 64 }
rlm@0 65
rlm@0 66
rlm@0 67 AL_API ALvoid AL_APIENTRY alListener3f(ALenum eParam, ALfloat flValue1, ALfloat flValue2, ALfloat flValue3)
rlm@0 68 {
rlm@0 69 ALCcontext *pContext;
rlm@0 70
rlm@0 71 pContext = GetLockedContext();
rlm@0 72 if(!pContext) return;
rlm@0 73
rlm@0 74 switch(eParam)
rlm@0 75 {
rlm@0 76 case AL_POSITION:
rlm@0 77 if(isfinite(flValue1) && isfinite(flValue2) && isfinite(flValue3))
rlm@0 78 {
rlm@0 79 pContext->Listener.Position[0] = flValue1;
rlm@0 80 pContext->Listener.Position[1] = flValue2;
rlm@0 81 pContext->Listener.Position[2] = flValue3;
rlm@0 82 pContext->UpdateSources = AL_TRUE;
rlm@0 83 }
rlm@0 84 else
rlm@0 85 alSetError(pContext, AL_INVALID_VALUE);
rlm@0 86 break;
rlm@0 87
rlm@0 88 case AL_VELOCITY:
rlm@0 89 if(isfinite(flValue1) && isfinite(flValue2) && isfinite(flValue3))
rlm@0 90 {
rlm@0 91 pContext->Listener.Velocity[0] = flValue1;
rlm@0 92 pContext->Listener.Velocity[1] = flValue2;
rlm@0 93 pContext->Listener.Velocity[2] = flValue3;
rlm@0 94 pContext->UpdateSources = AL_TRUE;
rlm@0 95 }
rlm@0 96 else
rlm@0 97 alSetError(pContext, AL_INVALID_VALUE);
rlm@0 98 break;
rlm@0 99
rlm@0 100 default:
rlm@0 101 alSetError(pContext, AL_INVALID_ENUM);
rlm@0 102 break;
rlm@0 103 }
rlm@0 104
rlm@0 105 UnlockContext(pContext);
rlm@0 106 }
rlm@0 107
rlm@0 108
rlm@0 109 AL_API ALvoid AL_APIENTRY alListenerfv(ALenum eParam, const ALfloat *pflValues)
rlm@0 110 {
rlm@0 111 ALCcontext *pContext;
rlm@0 112
rlm@0 113 if(pflValues)
rlm@0 114 {
rlm@0 115 switch(eParam)
rlm@0 116 {
rlm@0 117 case AL_GAIN:
rlm@0 118 case AL_METERS_PER_UNIT:
rlm@0 119 alListenerf(eParam, pflValues[0]);
rlm@0 120 return;
rlm@0 121
rlm@0 122 case AL_POSITION:
rlm@0 123 case AL_VELOCITY:
rlm@0 124 alListener3f(eParam, pflValues[0], pflValues[1], pflValues[2]);
rlm@0 125 return;
rlm@0 126 }
rlm@0 127 }
rlm@0 128
rlm@0 129 pContext = GetLockedContext();
rlm@0 130 if(!pContext) return;
rlm@0 131
rlm@0 132 if(pflValues)
rlm@0 133 {
rlm@0 134 switch(eParam)
rlm@0 135 {
rlm@0 136 case AL_ORIENTATION:
rlm@0 137 if(isfinite(pflValues[0]) && isfinite(pflValues[1]) &&
rlm@0 138 isfinite(pflValues[2]) && isfinite(pflValues[3]) &&
rlm@0 139 isfinite(pflValues[4]) && isfinite(pflValues[5]))
rlm@0 140 {
rlm@0 141 // AT then UP
rlm@0 142 pContext->Listener.Forward[0] = pflValues[0];
rlm@0 143 pContext->Listener.Forward[1] = pflValues[1];
rlm@0 144 pContext->Listener.Forward[2] = pflValues[2];
rlm@0 145 pContext->Listener.Up[0] = pflValues[3];
rlm@0 146 pContext->Listener.Up[1] = pflValues[4];
rlm@0 147 pContext->Listener.Up[2] = pflValues[5];
rlm@0 148 pContext->UpdateSources = AL_TRUE;
rlm@0 149 }
rlm@0 150 else
rlm@0 151 alSetError(pContext, AL_INVALID_VALUE);
rlm@0 152 break;
rlm@0 153
rlm@0 154 default:
rlm@0 155 alSetError(pContext, AL_INVALID_ENUM);
rlm@0 156 break;
rlm@0 157 }
rlm@0 158 }
rlm@0 159 else
rlm@0 160 alSetError(pContext, AL_INVALID_VALUE);
rlm@0 161
rlm@0 162 UnlockContext(pContext);
rlm@0 163 }
rlm@0 164
rlm@0 165
rlm@0 166 AL_API ALvoid AL_APIENTRY alListeneri(ALenum eParam, ALint lValue)
rlm@0 167 {
rlm@0 168 ALCcontext *pContext;
rlm@0 169
rlm@0 170 (void)lValue;
rlm@0 171
rlm@0 172 pContext = GetLockedContext();
rlm@0 173 if(!pContext) return;
rlm@0 174
rlm@0 175 switch(eParam)
rlm@0 176 {
rlm@0 177 default:
rlm@0 178 alSetError(pContext, AL_INVALID_ENUM);
rlm@0 179 break;
rlm@0 180 }
rlm@0 181
rlm@0 182 UnlockContext(pContext);
rlm@0 183 }
rlm@0 184
rlm@0 185
rlm@0 186 AL_API void AL_APIENTRY alListener3i(ALenum eParam, ALint lValue1, ALint lValue2, ALint lValue3)
rlm@0 187 {
rlm@0 188 ALCcontext *pContext;
rlm@0 189
rlm@0 190 switch(eParam)
rlm@0 191 {
rlm@0 192 case AL_POSITION:
rlm@0 193 case AL_VELOCITY:
rlm@0 194 alListener3f(eParam, (ALfloat)lValue1, (ALfloat)lValue2, (ALfloat)lValue3);
rlm@0 195 return;
rlm@0 196 }
rlm@0 197
rlm@0 198 pContext = GetLockedContext();
rlm@0 199 if(!pContext) return;
rlm@0 200
rlm@0 201 switch(eParam)
rlm@0 202 {
rlm@0 203 default:
rlm@0 204 alSetError(pContext, AL_INVALID_ENUM);
rlm@0 205 break;
rlm@0 206 }
rlm@0 207
rlm@0 208 UnlockContext(pContext);
rlm@0 209 }
rlm@0 210
rlm@0 211
rlm@0 212 AL_API void AL_APIENTRY alListeneriv( ALenum eParam, const ALint* plValues )
rlm@0 213 {
rlm@0 214 ALCcontext *pContext;
rlm@0 215 ALfloat flValues[6];
rlm@0 216
rlm@0 217 if(plValues)
rlm@0 218 {
rlm@0 219 switch(eParam)
rlm@0 220 {
rlm@0 221 case AL_POSITION:
rlm@0 222 case AL_VELOCITY:
rlm@0 223 alListener3f(eParam, plValues[0], plValues[1], plValues[2]);
rlm@0 224 return;
rlm@0 225
rlm@0 226 case AL_ORIENTATION:
rlm@0 227 flValues[0] = (ALfloat)plValues[0];
rlm@0 228 flValues[1] = (ALfloat)plValues[1];
rlm@0 229 flValues[2] = (ALfloat)plValues[2];
rlm@0 230 flValues[3] = (ALfloat)plValues[3];
rlm@0 231 flValues[4] = (ALfloat)plValues[4];
rlm@0 232 flValues[5] = (ALfloat)plValues[5];
rlm@0 233 alListenerfv(eParam, flValues);
rlm@0 234 return;
rlm@0 235 }
rlm@0 236 }
rlm@0 237
rlm@0 238 pContext = GetLockedContext();
rlm@0 239 if(!pContext) return;
rlm@0 240
rlm@0 241 if(plValues)
rlm@0 242 {
rlm@0 243 switch(eParam)
rlm@0 244 {
rlm@0 245 default:
rlm@0 246 alSetError(pContext, AL_INVALID_ENUM);
rlm@0 247 break;
rlm@0 248 }
rlm@0 249 }
rlm@0 250 else
rlm@0 251 alSetError(pContext, AL_INVALID_VALUE);
rlm@0 252
rlm@0 253 UnlockContext(pContext);
rlm@0 254 }
rlm@0 255
rlm@0 256
rlm@0 257 AL_API ALvoid AL_APIENTRY alGetListenerf(ALenum eParam, ALfloat *pflValue)
rlm@0 258 {
rlm@0 259 ALCcontext *pContext;
rlm@0 260
rlm@0 261 pContext = GetLockedContext();
rlm@0 262 if(!pContext) return;
rlm@0 263
rlm@0 264 if(pflValue)
rlm@0 265 {
rlm@0 266 switch(eParam)
rlm@0 267 {
rlm@0 268 case AL_GAIN:
rlm@0 269 *pflValue = pContext->Listener.Gain;
rlm@0 270 break;
rlm@0 271
rlm@0 272 case AL_METERS_PER_UNIT:
rlm@0 273 *pflValue = pContext->Listener.MetersPerUnit;
rlm@0 274 break;
rlm@0 275
rlm@0 276 default:
rlm@0 277 alSetError(pContext, AL_INVALID_ENUM);
rlm@0 278 break;
rlm@0 279 }
rlm@0 280 }
rlm@0 281 else
rlm@0 282 alSetError(pContext, AL_INVALID_VALUE);
rlm@0 283
rlm@0 284 UnlockContext(pContext);
rlm@0 285 }
rlm@0 286
rlm@0 287
rlm@0 288 AL_API ALvoid AL_APIENTRY alGetListener3f(ALenum eParam, ALfloat *pflValue1, ALfloat *pflValue2, ALfloat *pflValue3)
rlm@0 289 {
rlm@0 290 ALCcontext *pContext;
rlm@0 291
rlm@0 292 pContext = GetLockedContext();
rlm@0 293 if(!pContext) return;
rlm@0 294
rlm@0 295 if(pflValue1 && pflValue2 && pflValue3)
rlm@0 296 {
rlm@0 297 switch(eParam)
rlm@0 298 {
rlm@0 299 case AL_POSITION:
rlm@0 300 *pflValue1 = pContext->Listener.Position[0];
rlm@0 301 *pflValue2 = pContext->Listener.Position[1];
rlm@0 302 *pflValue3 = pContext->Listener.Position[2];
rlm@0 303 break;
rlm@0 304
rlm@0 305 case AL_VELOCITY:
rlm@0 306 *pflValue1 = pContext->Listener.Velocity[0];
rlm@0 307 *pflValue2 = pContext->Listener.Velocity[1];
rlm@0 308 *pflValue3 = pContext->Listener.Velocity[2];
rlm@0 309 break;
rlm@0 310
rlm@0 311 default:
rlm@0 312 alSetError(pContext, AL_INVALID_ENUM);
rlm@0 313 break;
rlm@0 314 }
rlm@0 315 }
rlm@0 316 else
rlm@0 317 alSetError(pContext, AL_INVALID_VALUE);
rlm@0 318
rlm@0 319 UnlockContext(pContext);
rlm@0 320 }
rlm@0 321
rlm@0 322
rlm@0 323 AL_API ALvoid AL_APIENTRY alGetListenerfv(ALenum eParam, ALfloat *pflValues)
rlm@0 324 {
rlm@0 325 ALCcontext *pContext;
rlm@0 326
rlm@0 327 switch(eParam)
rlm@0 328 {
rlm@0 329 case AL_GAIN:
rlm@0 330 case AL_METERS_PER_UNIT:
rlm@0 331 alGetListenerf(eParam, pflValues);
rlm@0 332 return;
rlm@0 333
rlm@0 334 case AL_POSITION:
rlm@0 335 case AL_VELOCITY:
rlm@0 336 alGetListener3f(eParam, pflValues+0, pflValues+1, pflValues+2);
rlm@0 337 return;
rlm@0 338 }
rlm@0 339
rlm@0 340 pContext = GetLockedContext();
rlm@0 341 if(!pContext) return;
rlm@0 342
rlm@0 343 if(pflValues)
rlm@0 344 {
rlm@0 345 switch(eParam)
rlm@0 346 {
rlm@0 347 case AL_ORIENTATION:
rlm@0 348 // AT then UP
rlm@0 349 pflValues[0] = pContext->Listener.Forward[0];
rlm@0 350 pflValues[1] = pContext->Listener.Forward[1];
rlm@0 351 pflValues[2] = pContext->Listener.Forward[2];
rlm@0 352 pflValues[3] = pContext->Listener.Up[0];
rlm@0 353 pflValues[4] = pContext->Listener.Up[1];
rlm@0 354 pflValues[5] = pContext->Listener.Up[2];
rlm@0 355 break;
rlm@0 356
rlm@0 357 default:
rlm@0 358 alSetError(pContext, AL_INVALID_ENUM);
rlm@0 359 break;
rlm@0 360 }
rlm@0 361 }
rlm@0 362 else
rlm@0 363 alSetError(pContext, AL_INVALID_VALUE);
rlm@0 364
rlm@0 365 UnlockContext(pContext);
rlm@0 366 }
rlm@0 367
rlm@0 368
rlm@0 369 AL_API ALvoid AL_APIENTRY alGetListeneri(ALenum eParam, ALint *plValue)
rlm@0 370 {
rlm@0 371 ALCcontext *pContext;
rlm@0 372
rlm@0 373 pContext = GetLockedContext();
rlm@0 374 if(!pContext) return;
rlm@0 375
rlm@0 376 if(plValue)
rlm@0 377 {
rlm@0 378 switch(eParam)
rlm@0 379 {
rlm@0 380 default:
rlm@0 381 alSetError(pContext, AL_INVALID_ENUM);
rlm@0 382 break;
rlm@0 383 }
rlm@0 384 }
rlm@0 385 else
rlm@0 386 alSetError(pContext, AL_INVALID_VALUE);
rlm@0 387
rlm@0 388 UnlockContext(pContext);
rlm@0 389 }
rlm@0 390
rlm@0 391
rlm@0 392 AL_API void AL_APIENTRY alGetListener3i(ALenum eParam, ALint *plValue1, ALint *plValue2, ALint *plValue3)
rlm@0 393 {
rlm@0 394 ALCcontext *pContext;
rlm@0 395
rlm@0 396 pContext = GetLockedContext();
rlm@0 397 if(!pContext) return;
rlm@0 398
rlm@0 399 if(plValue1 && plValue2 && plValue3)
rlm@0 400 {
rlm@0 401 switch (eParam)
rlm@0 402 {
rlm@0 403 case AL_POSITION:
rlm@0 404 *plValue1 = (ALint)pContext->Listener.Position[0];
rlm@0 405 *plValue2 = (ALint)pContext->Listener.Position[1];
rlm@0 406 *plValue3 = (ALint)pContext->Listener.Position[2];
rlm@0 407 break;
rlm@0 408
rlm@0 409 case AL_VELOCITY:
rlm@0 410 *plValue1 = (ALint)pContext->Listener.Velocity[0];
rlm@0 411 *plValue2 = (ALint)pContext->Listener.Velocity[1];
rlm@0 412 *plValue3 = (ALint)pContext->Listener.Velocity[2];
rlm@0 413 break;
rlm@0 414
rlm@0 415 default:
rlm@0 416 alSetError(pContext, AL_INVALID_ENUM);
rlm@0 417 break;
rlm@0 418 }
rlm@0 419 }
rlm@0 420 else
rlm@0 421 alSetError(pContext, AL_INVALID_VALUE);
rlm@0 422
rlm@0 423 UnlockContext(pContext);
rlm@0 424 }
rlm@0 425
rlm@0 426
rlm@0 427 AL_API void AL_APIENTRY alGetListeneriv(ALenum eParam, ALint* plValues)
rlm@0 428 {
rlm@0 429 ALCcontext *pContext;
rlm@0 430
rlm@0 431 switch(eParam)
rlm@0 432 {
rlm@0 433 case AL_POSITION:
rlm@0 434 case AL_VELOCITY:
rlm@0 435 alGetListener3i(eParam, plValues+0, plValues+1, plValues+2);
rlm@0 436 return;
rlm@0 437 }
rlm@0 438
rlm@0 439 pContext = GetLockedContext();
rlm@0 440 if(!pContext) return;
rlm@0 441
rlm@0 442 if(plValues)
rlm@0 443 {
rlm@0 444 switch(eParam)
rlm@0 445 {
rlm@0 446 case AL_ORIENTATION:
rlm@0 447 // AT then UP
rlm@0 448 plValues[0] = (ALint)pContext->Listener.Forward[0];
rlm@0 449 plValues[1] = (ALint)pContext->Listener.Forward[1];
rlm@0 450 plValues[2] = (ALint)pContext->Listener.Forward[2];
rlm@0 451 plValues[3] = (ALint)pContext->Listener.Up[0];
rlm@0 452 plValues[4] = (ALint)pContext->Listener.Up[1];
rlm@0 453 plValues[5] = (ALint)pContext->Listener.Up[2];
rlm@0 454 break;
rlm@0 455
rlm@0 456 default:
rlm@0 457 alSetError(pContext, AL_INVALID_ENUM);
rlm@0 458 break;
rlm@0 459 }
rlm@0 460 }
rlm@0 461 else
rlm@0 462 alSetError(pContext, AL_INVALID_VALUE);
rlm@0 463
rlm@0 464 UnlockContext(pContext);
rlm@0 465 }