PageRenderTime 22ms CodeModel.GetById 16ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 1ms

/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
  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
 29
 30#ifndef LL_AUDIOENGINE_OPENAL_H
 31#define LL_AUDIOENGINE_OPENAL_H
 32
 33#include "llaudioengine.h"
 34#include "lllistener_openal.h"
 35#include "llwindgen.h"
 36
 37class LLAudioEngine_OpenAL : public LLAudioEngine
 38{
 39	public:
 40		LLAudioEngine_OpenAL();
 41		virtual ~LLAudioEngine_OpenAL();
 42
 43		virtual bool init(const S32 num_channels, void *user_data);
 44        	virtual std::string getDriverName(bool verbose);
 45		virtual void allocateListener();
 46
 47		virtual void shutdown();
 48
 49		void setInternalGain(F32 gain);
 50
 51		LLAudioBuffer* createBuffer();
 52		LLAudioChannel* createChannel();
 53
 54		/*virtual*/ bool initWind();
 55		/*virtual*/ void cleanupWind();
 56		/*virtual*/ void updateWind(LLVector3 direction, F32 camera_altitude);
 57
 58	private:
 59		void * windDSP(void *newbuffer, int length);
 60        typedef S16 WIND_SAMPLE_T;
 61    	LLWindGen<WIND_SAMPLE_T> *mWindGen;
 62    	S16 *mWindBuf;
 63    	U32 mWindBufFreq;
 64    	U32 mWindBufSamples;
 65    	U32 mWindBufBytes;
 66    	ALuint mWindSource;
 67        int mNumEmptyWindALBuffers;
 68
 69    	static const int MAX_NUM_WIND_BUFFERS = 80;
 70    	static const float WIND_BUFFER_SIZE_SEC; // 1/20th sec
 71};
 72
 73class LLAudioChannelOpenAL : public LLAudioChannel
 74{
 75	public:
 76		LLAudioChannelOpenAL();
 77		virtual ~LLAudioChannelOpenAL();
 78	protected:
 79		/*virtual*/ void play();
 80		/*virtual*/ void playSynced(LLAudioChannel *channelp);
 81		/*virtual*/ void cleanup();
 82		/*virtual*/ bool isPlaying();
 83
 84		/*virtual*/ bool updateBuffer();
 85		/*virtual*/ void update3DPosition();
 86		/*virtual*/ void updateLoop();
 87
 88		ALuint mALSource;
 89	        ALint mLastSamplePos;
 90};
 91
 92class LLAudioBufferOpenAL : public LLAudioBuffer{
 93	public:
 94		LLAudioBufferOpenAL();
 95		virtual ~LLAudioBufferOpenAL();
 96
 97		bool loadWAV(const std::string& filename);
 98		U32 getLength();
 99
100		friend class LLAudioChannelOpenAL;
101	protected:
102		void cleanup();
103		ALuint getBuffer() {return mALBuffer;}
104
105		ALuint mALBuffer;
106};
107
108#endif