PageRenderTime 32ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llaudio/llaudioengine_openal.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 108 lines | 62 code | 19 blank | 27 comment | 0 complexity | 2e998688e3d774ca1334e8f5e10ce979 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. *
  7. * $LicenseInfo:firstyear=2002&license=viewerlgpl$
  8. * Second Life Viewer Source Code
  9. * Copyright (C) 2010, Linden Research, Inc.
  10. *
  11. * This library is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU Lesser General Public
  13. * License as published by the Free Software Foundation;
  14. * version 2.1 of the License only.
  15. *
  16. * This library is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * Lesser General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Lesser General Public
  22. * License along with this library; if not, write to the Free Software
  23. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  24. *
  25. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  26. * $/LicenseInfo$
  27. */
  28. #ifndef LL_AUDIOENGINE_OPENAL_H
  29. #define LL_AUDIOENGINE_OPENAL_H
  30. #include "llaudioengine.h"
  31. #include "lllistener_openal.h"
  32. #include "llwindgen.h"
  33. class LLAudioEngine_OpenAL : public LLAudioEngine
  34. {
  35. public:
  36. LLAudioEngine_OpenAL();
  37. virtual ~LLAudioEngine_OpenAL();
  38. virtual bool init(const S32 num_channels, void *user_data);
  39. virtual std::string getDriverName(bool verbose);
  40. virtual void allocateListener();
  41. virtual void shutdown();
  42. void setInternalGain(F32 gain);
  43. LLAudioBuffer* createBuffer();
  44. LLAudioChannel* createChannel();
  45. /*virtual*/ bool initWind();
  46. /*virtual*/ void cleanupWind();
  47. /*virtual*/ void updateWind(LLVector3 direction, F32 camera_altitude);
  48. private:
  49. void * windDSP(void *newbuffer, int length);
  50. typedef S16 WIND_SAMPLE_T;
  51. LLWindGen<WIND_SAMPLE_T> *mWindGen;
  52. S16 *mWindBuf;
  53. U32 mWindBufFreq;
  54. U32 mWindBufSamples;
  55. U32 mWindBufBytes;
  56. ALuint mWindSource;
  57. int mNumEmptyWindALBuffers;
  58. static const int MAX_NUM_WIND_BUFFERS = 80;
  59. static const float WIND_BUFFER_SIZE_SEC; // 1/20th sec
  60. };
  61. class LLAudioChannelOpenAL : public LLAudioChannel
  62. {
  63. public:
  64. LLAudioChannelOpenAL();
  65. virtual ~LLAudioChannelOpenAL();
  66. protected:
  67. /*virtual*/ void play();
  68. /*virtual*/ void playSynced(LLAudioChannel *channelp);
  69. /*virtual*/ void cleanup();
  70. /*virtual*/ bool isPlaying();
  71. /*virtual*/ bool updateBuffer();
  72. /*virtual*/ void update3DPosition();
  73. /*virtual*/ void updateLoop();
  74. ALuint mALSource;
  75. ALint mLastSamplePos;
  76. };
  77. class LLAudioBufferOpenAL : public LLAudioBuffer{
  78. public:
  79. LLAudioBufferOpenAL();
  80. virtual ~LLAudioBufferOpenAL();
  81. bool loadWAV(const std::string& filename);
  82. U32 getLength();
  83. friend class LLAudioChannelOpenAL;
  84. protected:
  85. void cleanup();
  86. ALuint getBuffer() {return mALBuffer;}
  87. ALuint mALBuffer;
  88. };
  89. #endif