PageRenderTime 13ms CodeModel.GetById 2ms app.highlight 9ms RepoModel.GetById 1ms 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
  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
 28#ifndef LL_AUDIOENGINE_FMOD_H
 29#define LL_AUDIOENGINE_FMOD_H
 30
 31#include "llaudioengine.h"
 32#include "lllistener_fmod.h"
 33#include "llwindgen.h"
 34
 35#include "fmod.h"
 36
 37class LLAudioStreamManagerFMOD;
 38
 39class LLAudioEngine_FMOD : public LLAudioEngine 
 40{
 41public:
 42	LLAudioEngine_FMOD();
 43	virtual ~LLAudioEngine_FMOD();
 44
 45	// initialization/startup/shutdown
 46	virtual bool init(const S32 num_channels, void *user_data);
 47       	virtual std::string getDriverName(bool verbose);
 48	virtual void allocateListener();
 49
 50	virtual void shutdown();
 51
 52	/*virtual*/ bool initWind();
 53	/*virtual*/ void cleanupWind();
 54
 55	/*virtual*/void updateWind(LLVector3 direction, F32 camera_height_above_water);
 56
 57#if LL_DARWIN
 58	typedef S32 MIXBUFFERFORMAT;
 59#else
 60	typedef S16 MIXBUFFERFORMAT;
 61#endif
 62
 63protected:
 64	/*virtual*/ LLAudioBuffer *createBuffer(); // Get a free buffer, or flush an existing one if you have to.
 65	/*virtual*/ LLAudioChannel *createChannel(); // Create a new audio channel.
 66
 67	/*virtual*/ void setInternalGain(F32 gain);
 68protected:
 69	static signed char F_CALLBACKAPI callbackMetaData(char* name, char* value, void* userdata);
 70
 71	//F32 mMinDistance[MAX_BUFFERS];
 72	//F32 mMaxDistance[MAX_BUFFERS];
 73
 74	bool mInited;
 75
 76	// On Windows, userdata is the HWND of the application window.
 77	void* mUserData;
 78
 79	LLWindGen<MIXBUFFERFORMAT> *mWindGen;
 80	FSOUND_DSPUNIT *mWindDSP;
 81};
 82
 83
 84class LLAudioChannelFMOD : public LLAudioChannel
 85{
 86public:
 87	LLAudioChannelFMOD();
 88	virtual ~LLAudioChannelFMOD();
 89
 90protected:
 91	/*virtual*/ void play();
 92	/*virtual*/ void playSynced(LLAudioChannel *channelp);
 93	/*virtual*/ void cleanup();
 94	/*virtual*/ bool isPlaying();
 95
 96	/*virtual*/ bool updateBuffer();
 97	/*virtual*/ void update3DPosition();
 98	/*virtual*/ void updateLoop();
 99
100protected:
101	int mChannelID;
102	S32 mLastSamplePos;
103};
104
105
106class LLAudioBufferFMOD : public LLAudioBuffer
107{
108public:
109	LLAudioBufferFMOD();
110	virtual ~LLAudioBufferFMOD();
111
112	/*virtual*/ bool loadWAV(const std::string& filename);
113	/*virtual*/ U32 getLength();
114	friend class LLAudioChannelFMOD;
115
116	void set3DMode(bool use3d);
117protected:
118	FSOUND_SAMPLE *getSample()	{ return mSamplep; }
119protected:
120	FSOUND_SAMPLE *mSamplep;
121};
122
123
124#endif // LL_AUDIOENGINE_FMOD_H