diff options
Diffstat (limited to 'linden/indra/llaudio/llaudioengine_openal.h')
-rw-r--r-- | linden/indra/llaudio/llaudioengine_openal.h | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/linden/indra/llaudio/llaudioengine_openal.h b/linden/indra/llaudio/llaudioengine_openal.h new file mode 100644 index 0000000..900bcb3 --- /dev/null +++ b/linden/indra/llaudio/llaudioengine_openal.h | |||
@@ -0,0 +1,113 @@ | |||
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=viewergpl$ | ||
8 | * | ||
9 | * Copyright (c) 2002-2009, Linden Research, Inc. | ||
10 | * | ||
11 | * Second Life Viewer Source Code | ||
12 | * The source code in this file ("Source Code") is provided by Linden Lab | ||
13 | * to you under the terms of the GNU General Public License, version 2.0 | ||
14 | * ("GPL"), unless you have obtained a separate licensing agreement | ||
15 | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
16 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
17 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
18 | * | ||
19 | * There are special exceptions to the terms and conditions of the GPL as | ||
20 | * it is applied to this Source Code. View the full text of the exception | ||
21 | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
22 | * online at | ||
23 | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
24 | * | ||
25 | * By copying, modifying or distributing this software, you acknowledge | ||
26 | * that you have read and understood your obligations described above, | ||
27 | * and agree to abide by those obligations. | ||
28 | * | ||
29 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
30 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
31 | * COMPLETENESS OR PERFORMANCE. | ||
32 | * $/LicenseInfo$ | ||
33 | */ | ||
34 | |||
35 | |||
36 | #ifndef LL_AUDIOENGINE_OPENAL_H | ||
37 | #define LL_AUDIOENGINE_OPENAL_H | ||
38 | |||
39 | #include "llaudioengine.h" | ||
40 | #include "lllistener_openal.h" | ||
41 | #include "llwindgen.h" | ||
42 | |||
43 | class LLAudioEngine_OpenAL : public LLAudioEngine | ||
44 | { | ||
45 | public: | ||
46 | LLAudioEngine_OpenAL(); | ||
47 | virtual ~LLAudioEngine_OpenAL(); | ||
48 | |||
49 | virtual bool init(const S32 num_channels, void *user_data); | ||
50 | virtual std::string getDriverName(bool verbose); | ||
51 | virtual void allocateListener(); | ||
52 | |||
53 | virtual void shutdown(); | ||
54 | |||
55 | void setInternalGain(F32 gain); | ||
56 | |||
57 | LLAudioBuffer* createBuffer(); | ||
58 | LLAudioChannel* createChannel(); | ||
59 | |||
60 | /*virtual*/ void initWind(); | ||
61 | /*virtual*/ void cleanupWind(); | ||
62 | /*virtual*/ void updateWind(LLVector3 direction, F32 camera_altitude); | ||
63 | |||
64 | private: | ||
65 | void * windDSP(void *newbuffer, int length); | ||
66 | typedef S16 WIND_SAMPLE_T; | ||
67 | LLWindGen<WIND_SAMPLE_T> *mWindGen; | ||
68 | S16 *mWindBuf; | ||
69 | U32 mWindBufFreq; | ||
70 | U32 mWindBufSamples; | ||
71 | U32 mWindBufBytes; | ||
72 | ALuint mWindSource; | ||
73 | int mNumEmptyWindALBuffers; | ||
74 | |||
75 | static const int MAX_NUM_WIND_BUFFERS = 80; | ||
76 | }; | ||
77 | |||
78 | class LLAudioChannelOpenAL : public LLAudioChannel | ||
79 | { | ||
80 | public: | ||
81 | LLAudioChannelOpenAL(); | ||
82 | virtual ~LLAudioChannelOpenAL(); | ||
83 | protected: | ||
84 | /*virtual*/ void play(); | ||
85 | /*virtual*/ void playSynced(LLAudioChannel *channelp); | ||
86 | /*virtual*/ void cleanup(); | ||
87 | /*virtual*/ bool isPlaying(); | ||
88 | |||
89 | /*virtual*/ bool updateBuffer(); | ||
90 | /*virtual*/ void update3DPosition(); | ||
91 | /*virtual*/ void updateLoop(); | ||
92 | |||
93 | ALuint mALSource; | ||
94 | ALint mLastSamplePos; | ||
95 | }; | ||
96 | |||
97 | class LLAudioBufferOpenAL : public LLAudioBuffer{ | ||
98 | public: | ||
99 | LLAudioBufferOpenAL(); | ||
100 | virtual ~LLAudioBufferOpenAL(); | ||
101 | |||
102 | bool loadWAV(const std::string& filename); | ||
103 | U32 getLength(); | ||
104 | |||
105 | friend class LLAudioChannelOpenAL; | ||
106 | protected: | ||
107 | void cleanup(); | ||
108 | ALuint getBuffer() {return mALBuffer;} | ||
109 | |||
110 | ALuint mALBuffer; | ||
111 | }; | ||
112 | |||
113 | #endif | ||