aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llaudio/audioengine_openal.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llaudio/audioengine_openal.h112
1 files changed, 112 insertions, 0 deletions
diff --git a/linden/indra/llaudio/audioengine_openal.h b/linden/indra/llaudio/audioengine_openal.h
new file mode 100644
index 0000000..1f6dee4
--- /dev/null
+++ b/linden/indra/llaudio/audioengine_openal.h
@@ -0,0 +1,112 @@
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-2008, 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 http://secondlifegrid.net/programs/open_source/licensing/flossexception
23 *
24 * By copying, modifying or distributing this software, you acknowledge
25 * that you have read and understood your obligations described above,
26 * and agree to abide by those obligations.
27 *
28 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
29 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
30 * COMPLETENESS OR PERFORMANCE.
31 * $/LicenseInfo$
32 */
33
34
35#ifndef LL_AUDIOENGINE_OPENAL_H
36#define LL_AUDIOENGINE_OPENAL_H
37
38#include "audioengine.h"
39#include "listener_openal.h"
40#include "windgen.h"
41
42class LLAudioEngine_OpenAL : public LLAudioEngine
43{
44 public:
45 LLAudioEngine_OpenAL();
46 virtual ~LLAudioEngine_OpenAL();
47
48 virtual bool init(const S32 num_channels, void *user_data);
49 virtual std::string getDriverName(bool verbose);
50 virtual void allocateListener();
51
52 virtual void shutdown();
53
54 void setInternalGain(F32 gain);
55
56 LLAudioBuffer* createBuffer();
57 LLAudioChannel* createChannel();
58
59 /*virtual*/ void initWind();
60 /*virtual*/ void cleanupWind();
61 /*virtual*/ void updateWind(LLVector3 direction, F32 camera_altitude);
62
63 private:
64 void * windDSP(void *newbuffer, int length);
65 typedef S16 WIND_SAMPLE_T;
66 LLWindGen<WIND_SAMPLE_T> *mWindGen;
67 S16 *mWindBuf;
68 U32 mWindBufFreq;
69 U32 mWindBufSamples;
70 U32 mWindBufBytes;
71 ALuint mWindSource;
72 int mNumEmptyWindALBuffers;
73
74 static const int MAX_NUM_WIND_BUFFERS = 80;
75};
76
77class LLAudioChannelOpenAL : public LLAudioChannel
78{
79 public:
80 LLAudioChannelOpenAL();
81 virtual ~LLAudioChannelOpenAL();
82 protected:
83 /*virtual*/ void play();
84 /*virtual*/ void playSynced(LLAudioChannel *channelp);
85 /*virtual*/ void cleanup();
86 /*virtual*/ bool isPlaying();
87
88 /*virtual*/ bool updateBuffer();
89 /*virtual*/ void update3DPosition();
90 /*virtual*/ void updateLoop();
91
92 ALuint mALSource;
93 ALint mLastSamplePos;
94};
95
96class LLAudioBufferOpenAL : public LLAudioBuffer{
97 public:
98 LLAudioBufferOpenAL();
99 virtual ~LLAudioBufferOpenAL();
100
101 bool loadWAV(const std::string& filename);
102 U32 getLength();
103
104 friend class LLAudioChannelOpenAL;
105 protected:
106 void cleanup();
107 ALuint getBuffer() {return mALBuffer;}
108
109 ALuint mALBuffer;
110};
111
112#endif