PageRenderTime 71ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llaudio/lllistener_openal.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 110 lines | 61 code | 18 blank | 31 comment | 0 complexity | 523b501681d72adcbad6fabe5eb2d6cd MD5 | raw file
Possible License(s): LGPL-2.1
  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=viewerlgpl$
  7. * Second Life Viewer Source Code
  8. * Copyright (C) 2010, Linden Research, Inc.
  9. *
  10. * This library is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU Lesser General Public
  12. * License as published by the Free Software Foundation;
  13. * version 2.1 of the License only.
  14. *
  15. * This library is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  18. * Lesser General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU Lesser General Public
  21. * License along with this library; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  23. *
  24. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  25. * $/LicenseInfo$
  26. */
  27. #include "linden_common.h"
  28. #include "llaudioengine.h"
  29. #include "lllistener_openal.h"
  30. LLListener_OpenAL::LLListener_OpenAL()
  31. {
  32. init();
  33. }
  34. LLListener_OpenAL::~LLListener_OpenAL()
  35. {
  36. }
  37. void LLListener_OpenAL::translate(LLVector3 offset)
  38. {
  39. //llinfos << "LLListener_OpenAL::translate() : " << offset << llendl;
  40. LLListener::translate(offset);
  41. }
  42. void LLListener_OpenAL::setPosition(LLVector3 pos)
  43. {
  44. //llinfos << "LLListener_OpenAL::setPosition() : " << pos << llendl;
  45. LLListener::setPosition(pos);
  46. }
  47. void LLListener_OpenAL::setVelocity(LLVector3 vel)
  48. {
  49. LLListener::setVelocity(vel);
  50. }
  51. void LLListener_OpenAL::orient(LLVector3 up, LLVector3 at)
  52. {
  53. //llinfos << "LLListener_OpenAL::orient() up: " << up << " at: " << at << llendl;
  54. LLListener::orient(up, at);
  55. }
  56. void LLListener_OpenAL::commitDeferredChanges()
  57. {
  58. ALfloat orientation[6];
  59. orientation[0] = mListenAt.mV[0];
  60. orientation[1] = mListenAt.mV[1];
  61. orientation[2] = mListenAt.mV[2];
  62. orientation[3] = mListenUp.mV[0];
  63. orientation[4] = mListenUp.mV[1];
  64. orientation[5] = mListenUp.mV[2];
  65. ALfloat velocity[3];
  66. velocity[0] = mVelocity.mV[0];
  67. velocity[1] = mVelocity.mV[1];
  68. velocity[2] = mVelocity.mV[2];
  69. alListenerfv(AL_ORIENTATION, orientation);
  70. alListenerfv(AL_POSITION, mPosition.mV);
  71. alListenerfv(AL_VELOCITY, velocity);
  72. }
  73. void LLListener_OpenAL::setDopplerFactor(F32 factor)
  74. {
  75. //llinfos << "LLListener_OpenAL::setDopplerFactor() : " << factor << llendl;
  76. alDopplerFactor(factor);
  77. }
  78. F32 LLListener_OpenAL::getDopplerFactor()
  79. {
  80. ALfloat factor;
  81. factor = alGetFloat(AL_DOPPLER_FACTOR);
  82. //llinfos << "LLListener_OpenAL::getDopplerFactor() : " << factor << llendl;
  83. return factor;
  84. }
  85. void LLListener_OpenAL::setRolloffFactor(F32 factor)
  86. {
  87. mRolloffFactor = factor;
  88. }
  89. F32 LLListener_OpenAL::getRolloffFactor()
  90. {
  91. return mRolloffFactor;
  92. }