diff options
author | Jacek Antonelli | 2008-12-06 14:03:10 -0600 |
---|---|---|
committer | Jacek Antonelli | 2008-12-06 14:03:10 -0600 |
commit | b29b13ad98c5c79fd63bae10b4b099a03fa9dc35 (patch) | |
tree | ffc14fd638344c84287d1c4a72d2de5f765bf3c8 /linden/indra/llaudio/audioengine_openal.h | |
parent | openal on windows branch (diff) | |
download | meta-impy-b29b13ad98c5c79fd63bae10b4b099a03fa9dc35.zip meta-impy-b29b13ad98c5c79fd63bae10b4b099a03fa9dc35.tar.gz meta-impy-b29b13ad98c5c79fd63bae10b4b099a03fa9dc35.tar.bz2 meta-impy-b29b13ad98c5c79fd63bae10b4b099a03fa9dc35.tar.xz |
Updated audio engine to LL's openal branch r1532.
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llaudio/audioengine_openal.h | 107 |
1 files changed, 41 insertions, 66 deletions
diff --git a/linden/indra/llaudio/audioengine_openal.h b/linden/indra/llaudio/audioengine_openal.h index 5d5c7d8..b03153a 100644 --- a/linden/indra/llaudio/audioengine_openal.h +++ b/linden/indra/llaudio/audioengine_openal.h | |||
@@ -3,27 +3,28 @@ | |||
3 | * @brief implementation of audio engine using OpenAL | 3 | * @brief implementation of audio engine using OpenAL |
4 | * support as a OpenAL 3D implementation | 4 | * support as a OpenAL 3D implementation |
5 | * | 5 | * |
6 | * Copyright (c) 2002-2008, Linden Research, Inc. | ||
7 | * | 6 | * |
8 | * $LicenseInfo:firstyear=2002&license=viewergpl$ | 7 | * $LicenseInfo:firstyear=2002&license=viewergpl$ |
9 | * | 8 | * |
9 | * Copyright (c) 2002-2008, Linden Research, Inc. | ||
10 | * | ||
10 | * Second Life Viewer Source Code | 11 | * Second Life Viewer Source Code |
11 | * The source code in this file ("Source Code") is provided by Linden Lab | 12 | * The source code in this file ("Source Code") is provided by Linden Lab |
12 | * to you under the terms of the GNU General Public License, version 2.0 | 13 | * to you under the terms of the GNU General Public License, version 2.0 |
13 | * ("GPL"), unless you have obtained a separate licensing agreement | 14 | * ("GPL"), unless you have obtained a separate licensing agreement |
14 | * ("Other License"), formally executed by you and Linden Lab. Terms of | 15 | * ("Other License"), formally executed by you and Linden Lab. Terms of |
15 | * the GPL can be found in doc/GPL-license.txt in this distribution, or | 16 | * the GPL can be found in doc/GPL-license.txt in this distribution, or |
16 | * online at http://secondlife.com/developers/opensource/gplv2 | 17 | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 |
17 | * | 18 | * |
18 | * There are special exceptions to the terms and conditions of the GPL as | 19 | * There are special exceptions to the terms and conditions of the GPL as |
19 | * it is applied to this Source Code. View the full text of the exception | 20 | * it is applied to this Source Code. View the full text of the exception |
20 | * in the file doc/FLOSS-exception.txt in this software distribution, or | 21 | * in the file doc/FLOSS-exception.txt in this software distribution, or |
21 | * online at http://secondlife.com/developers/opensource/flossexception | 22 | * online at http://secondlifegrid.net/programs/open_source/licensing/flossexception |
22 | * | 23 | * |
23 | * By copying, modifying or distributing this software, you acknowledge | 24 | * By copying, modifying or distributing this software, you acknowledge |
24 | * that you have read and understood your obligations described above, | 25 | * that you have read and understood your obligations described above, |
25 | * and agree to abide by those obligations. | 26 | * and agree to abide by those obligations. |
26 | * | 27 | * |
27 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | 28 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO |
28 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | 29 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, |
29 | * COMPLETENESS OR PERFORMANCE. | 30 | * COMPLETENESS OR PERFORMANCE. |
@@ -31,16 +32,12 @@ | |||
31 | */ | 32 | */ |
32 | 33 | ||
33 | 34 | ||
34 | #ifndef LL_AUDIOENGINE_OpenAL_H | 35 | #ifndef LL_AUDIOENGINE_OPENAL_H |
35 | #define LL_AUDIOENGINE_OpenAL_H | 36 | #define LL_AUDIOENGINE_OPENAL_H |
36 | |||
37 | #include <string> | ||
38 | 37 | ||
39 | #include "audioengine.h" | 38 | #include "audioengine.h" |
40 | #include "listener_openal.h" | 39 | #include "listener_openal.h" |
41 | #include "llmediamanager.h" | 40 | #include "windgen.h" |
42 | #include "llmediaimplgstreamer.h" | ||
43 | #include "llrand.h" | ||
44 | 41 | ||
45 | class LLAudioEngine_OpenAL : public LLAudioEngine | 42 | class LLAudioEngine_OpenAL : public LLAudioEngine |
46 | { | 43 | { |
@@ -48,58 +45,34 @@ class LLAudioEngine_OpenAL : public LLAudioEngine | |||
48 | LLAudioEngine_OpenAL(); | 45 | LLAudioEngine_OpenAL(); |
49 | virtual ~LLAudioEngine_OpenAL(); | 46 | virtual ~LLAudioEngine_OpenAL(); |
50 | 47 | ||
51 | virtual BOOL init(const S32 num_channels); | 48 | virtual bool init(const S32 num_channels, void *user_data); |
52 | virtual std::string getDriverName(bool verbose); | 49 | virtual std::string getDriverName(bool verbose); |
53 | virtual void allocateListener(); | 50 | virtual void allocateListener(); |
54 | 51 | ||
55 | virtual void shutdown(); | 52 | virtual void shutdown(); |
56 | 53 | ||
57 | virtual void idle(F32 max_decode_time = 0.f); | ||
58 | |||
59 | void setInternalGain(F32 gain); | 54 | void setInternalGain(F32 gain); |
60 | 55 | ||
61 | LLAudioBuffer* createBuffer(); | 56 | LLAudioBuffer* createBuffer(); |
62 | LLAudioChannel* createChannel(); | 57 | LLAudioChannel* createChannel(); |
63 | 58 | ||
64 | // Internet stream methods | 59 | /*virtual*/ void initWind(); |
65 | virtual void initInternetStream(); | 60 | /*virtual*/ void cleanupWind(); |
66 | virtual void startInternetStream(const std::string& url_cstr); | 61 | /*virtual*/ void updateWind(LLVector3 direction, F32 camera_altitude); |
67 | virtual void stopInternetStream(); | 62 | |
68 | virtual void updateInternetStream(); | 63 | private: |
69 | virtual void pauseInternetStream(int pause); | ||
70 | virtual int isInternetStreamPlaying(); | ||
71 | virtual void getInternetStreamInfo(char* artist, char* title); | ||
72 | virtual void setInternetStreamGain(F32 vol); | ||
73 | virtual const std::string& getInternetStreamURL(); | ||
74 | virtual void InitStreamer(); | ||
75 | |||
76 | void checkALError(); | ||
77 | |||
78 | void initWind(); | ||
79 | void cleanupWind(); | ||
80 | void updateWind(LLVector3 direction, F32 camera_altitude); | ||
81 | |||
82 | protected: | ||
83 | static const S32 mNumWindBuffers=20; | ||
84 | static const S32 mSampleRate=44100; | ||
85 | static const S32 mBytesPerSample=4; | ||
86 | static const S32 mWindDataSize=8820; //44100 * 0.200 * 2 channels * 2 bytes per sample | ||
87 | |||
88 | BOOL mFirstWind; | ||
89 | ALuint mWindBuffers[mNumWindBuffers]; | ||
90 | ALuint mWindSource; | ||
91 | |||
92 | F32 mTargetGain; | ||
93 | F32 mTargetFreq; | ||
94 | F32 mTargetPanGainR; | ||
95 | S16 mWindData[mWindDataSize]; | ||
96 | |||
97 | std::string mInternetStreamURL; | ||
98 | void * windDSP(void *newbuffer, int length); | 64 | void * windDSP(void *newbuffer, int length); |
99 | #if LL_GSTREAMER_ENABLED | 65 | typedef S16 WIND_SAMPLE_T; |
100 | LLMediaManagerData * mMedia_data; | 66 | LLWindGen<WIND_SAMPLE_T> *mWindGen; |
101 | LLMediaImplGStreamer * m_streamer; | 67 | S16 *mWindBuf; |
102 | #endif | 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 | static const float WIND_BUFFER_SIZE_SEC = 0.05f; // 1/20th sec | ||
103 | }; | 76 | }; |
104 | 77 | ||
105 | class LLAudioChannelOpenAL : public LLAudioChannel | 78 | class LLAudioChannelOpenAL : public LLAudioChannel |
@@ -108,16 +81,17 @@ class LLAudioChannelOpenAL : public LLAudioChannel | |||
108 | LLAudioChannelOpenAL(); | 81 | LLAudioChannelOpenAL(); |
109 | virtual ~LLAudioChannelOpenAL(); | 82 | virtual ~LLAudioChannelOpenAL(); |
110 | protected: | 83 | protected: |
111 | void play(); | 84 | /*virtual*/ void play(); |
112 | void playSynced(LLAudioChannel *channelp); | 85 | /*virtual*/ void playSynced(LLAudioChannel *channelp); |
113 | void cleanup(); | 86 | /*virtual*/ void cleanup(); |
114 | bool isPlaying(); | 87 | /*virtual*/ bool isPlaying(); |
115 | 88 | ||
116 | bool updateBuffer(); | 89 | /*virtual*/ bool updateBuffer(); |
117 | void update3DPosition(); | 90 | /*virtual*/ void update3DPosition(); |
118 | void updateLoop(){}; | 91 | /*virtual*/ void updateLoop(); |
119 | 92 | ||
120 | ALuint ALSource; | 93 | ALuint mALSource; |
94 | ALint mLastSamplePos; | ||
121 | }; | 95 | }; |
122 | 96 | ||
123 | class LLAudioBufferOpenAL : public LLAudioBuffer{ | 97 | class LLAudioBufferOpenAL : public LLAudioBuffer{ |
@@ -131,8 +105,9 @@ class LLAudioBufferOpenAL : public LLAudioBuffer{ | |||
131 | friend class LLAudioChannelOpenAL; | 105 | friend class LLAudioChannelOpenAL; |
132 | protected: | 106 | protected: |
133 | void cleanup(); | 107 | void cleanup(); |
134 | ALuint getBuffer(){return ALBuffer;} | 108 | ALuint getBuffer() {return mALBuffer;} |
135 | ALuint ALBuffer; | 109 | |
110 | ALuint mALBuffer; | ||
136 | }; | 111 | }; |
137 | 112 | ||
138 | #endif | 113 | #endif |