PageRenderTime 36ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llaudio/llaudioengine_fmod.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 124 lines | 67 code | 27 blank | 30 comment | 0 complexity | 58a3a3b3075b6fff69a57d39b0022a65 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file audioengine_fmod.h
  3. * @brief Definition of LLAudioEngine class abstracting the audio
  4. * support as a FMOD 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. #ifndef LL_AUDIOENGINE_FMOD_H
  28. #define LL_AUDIOENGINE_FMOD_H
  29. #include "llaudioengine.h"
  30. #include "lllistener_fmod.h"
  31. #include "llwindgen.h"
  32. #include "fmod.h"
  33. class LLAudioStreamManagerFMOD;
  34. class LLAudioEngine_FMOD : public LLAudioEngine
  35. {
  36. public:
  37. LLAudioEngine_FMOD();
  38. virtual ~LLAudioEngine_FMOD();
  39. // initialization/startup/shutdown
  40. virtual bool init(const S32 num_channels, void *user_data);
  41. virtual std::string getDriverName(bool verbose);
  42. virtual void allocateListener();
  43. virtual void shutdown();
  44. /*virtual*/ bool initWind();
  45. /*virtual*/ void cleanupWind();
  46. /*virtual*/void updateWind(LLVector3 direction, F32 camera_height_above_water);
  47. #if LL_DARWIN
  48. typedef S32 MIXBUFFERFORMAT;
  49. #else
  50. typedef S16 MIXBUFFERFORMAT;
  51. #endif
  52. protected:
  53. /*virtual*/ LLAudioBuffer *createBuffer(); // Get a free buffer, or flush an existing one if you have to.
  54. /*virtual*/ LLAudioChannel *createChannel(); // Create a new audio channel.
  55. /*virtual*/ void setInternalGain(F32 gain);
  56. protected:
  57. static signed char F_CALLBACKAPI callbackMetaData(char* name, char* value, void* userdata);
  58. //F32 mMinDistance[MAX_BUFFERS];
  59. //F32 mMaxDistance[MAX_BUFFERS];
  60. bool mInited;
  61. // On Windows, userdata is the HWND of the application window.
  62. void* mUserData;
  63. LLWindGen<MIXBUFFERFORMAT> *mWindGen;
  64. FSOUND_DSPUNIT *mWindDSP;
  65. };
  66. class LLAudioChannelFMOD : public LLAudioChannel
  67. {
  68. public:
  69. LLAudioChannelFMOD();
  70. virtual ~LLAudioChannelFMOD();
  71. protected:
  72. /*virtual*/ void play();
  73. /*virtual*/ void playSynced(LLAudioChannel *channelp);
  74. /*virtual*/ void cleanup();
  75. /*virtual*/ bool isPlaying();
  76. /*virtual*/ bool updateBuffer();
  77. /*virtual*/ void update3DPosition();
  78. /*virtual*/ void updateLoop();
  79. protected:
  80. int mChannelID;
  81. S32 mLastSamplePos;
  82. };
  83. class LLAudioBufferFMOD : public LLAudioBuffer
  84. {
  85. public:
  86. LLAudioBufferFMOD();
  87. virtual ~LLAudioBufferFMOD();
  88. /*virtual*/ bool loadWAV(const std::string& filename);
  89. /*virtual*/ U32 getLength();
  90. friend class LLAudioChannelFMOD;
  91. void set3DMode(bool use3d);
  92. protected:
  93. FSOUND_SAMPLE *getSample() { return mSamplep; }
  94. protected:
  95. FSOUND_SAMPLE *mSamplep;
  96. };
  97. #endif // LL_AUDIOENGINE_FMOD_H