lllistener_openal.cpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**
  2. * @file audioengine_openal.cpp
  3. * @brief implementation of audio engine using OpenAL
  4. * support as a OpenAL 3D implementation
  5. *
  6. * $LicenseInfo:firstyear=2002&license=viewergpl$
  7. *
  8. * Copyright (c) 2002-2009, Linden Research, Inc.
  9. *
  10. * Second Life Viewer Source Code
  11. * The source code in this file ("Source Code") is provided by Linden Lab
  12. * to you under the terms of the GNU General Public License, version 2.0
  13. * ("GPL"), unless you have obtained a separate licensing agreement
  14. * ("Other License"), formally executed by you and Linden Lab. Terms of
  15. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  16. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  17. *
  18. * There are special exceptions to the terms and conditions of the GPL as
  19. * it is applied to this Source Code. View the full text of the exception
  20. * in the file doc/FLOSS-exception.txt in this software distribution, or
  21. * online at
  22. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  23. *
  24. * By copying, modifying or distributing this software, you acknowledge
  25. * that you have read and understood your obligations described above,
  26. * and agree to abide by those obligations.
  27. *
  28. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  29. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  30. * COMPLETENESS OR PERFORMANCE.
  31. * $/LicenseInfo$
  32. */
  33. #include "linden_common.h"
  34. #include "llaudioengine.h"
  35. #include "lllistener_openal.h"
  36. // After #include "lllistener_openal.h" so that "AL/al.h" is included
  37. // already. HB
  38. #include "AL/alut.h"
  39. #include "AL/alext.h"
  40. LLListener_OpenAL::LLListener_OpenAL()
  41. : LLListener()
  42. {
  43. }
  44. //virtual
  45. void LLListener_OpenAL::setDopplerFactor(F32 factor)
  46. {
  47. mDopplerFactor = factor;
  48. alDopplerFactor(factor);
  49. }
  50. //virtual
  51. F32 LLListener_OpenAL::getDopplerFactor()
  52. {
  53. mDopplerFactor = (F32)alGetFloat(AL_DOPPLER_FACTOR);
  54. return mDopplerFactor;
  55. }
  56. //virtual
  57. void LLListener_OpenAL::commitDeferredChanges()
  58. {
  59. ALfloat orientation[6];
  60. orientation[0] = mListenAt.mV[0];
  61. orientation[1] = mListenAt.mV[1];
  62. orientation[2] = mListenAt.mV[2];
  63. orientation[3] = mListenUp.mV[0];
  64. orientation[4] = mListenUp.mV[1];
  65. orientation[5] = mListenUp.mV[2];
  66. ALfloat velocity[3];
  67. velocity[0] = mVelocity.mV[0];
  68. velocity[1] = mVelocity.mV[1];
  69. velocity[2] = mVelocity.mV[2];
  70. alListenerfv(AL_ORIENTATION, orientation);
  71. alListenerfv(AL_POSITION, mPosition.mV);
  72. alListenerfv(AL_VELOCITY, velocity);
  73. }