aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llaudio/audioengine.h
diff options
context:
space:
mode:
authorJacek Antonelli2009-02-12 02:06:41 -0600
committerJacek Antonelli2009-02-12 02:06:45 -0600
commit61f97b33f9850d21965d397b947a298c16ba576d (patch)
treea2edff0a7fbc83e2259eda952511b0fbdbea290b /linden/indra/llaudio/audioengine.h
parentSecond Life viewer sources 1.22.7-RC (diff)
downloadmeta-impy-61f97b33f9850d21965d397b947a298c16ba576d.zip
meta-impy-61f97b33f9850d21965d397b947a298c16ba576d.tar.gz
meta-impy-61f97b33f9850d21965d397b947a298c16ba576d.tar.bz2
meta-impy-61f97b33f9850d21965d397b947a298c16ba576d.tar.xz
Second Life viewer sources 1.22.8-RC
Diffstat (limited to 'linden/indra/llaudio/audioengine.h')
-rw-r--r--linden/indra/llaudio/audioengine.h134
1 files changed, 68 insertions, 66 deletions
diff --git a/linden/indra/llaudio/audioengine.h b/linden/indra/llaudio/audioengine.h
index 0bd6327..b582f14 100644
--- a/linden/indra/llaudio/audioengine.h
+++ b/linden/indra/llaudio/audioengine.h
@@ -45,6 +45,8 @@
45#include "llframetimer.h" 45#include "llframetimer.h"
46#include "llassettype.h" 46#include "llassettype.h"
47 47
48class LLMediaBase;
49
48const F32 LL_WIND_UPDATE_INTERVAL = 0.1f; 50const F32 LL_WIND_UPDATE_INTERVAL = 0.1f;
49const F32 LL_ROLLOFF_MULTIPLIER_UNDER_WATER = 5.f; // How much sounds are weaker under water 51const F32 LL_ROLLOFF_MULTIPLIER_UNDER_WATER = 5.f; // How much sounds are weaker under water
50const F32 LL_WIND_UNDERWATER_CENTER_FREQ = 20.f; 52const F32 LL_WIND_UNDERWATER_CENTER_FREQ = 20.f;
@@ -67,6 +69,7 @@ class LLVFS;
67class LLAudioSource; 69class LLAudioSource;
68class LLAudioData; 70class LLAudioData;
69class LLAudioChannel; 71class LLAudioChannel;
72class LLAudioChannelOpenAL;
70class LLAudioBuffer; 73class LLAudioBuffer;
71 74
72 75
@@ -77,6 +80,8 @@ class LLAudioBuffer;
77 80
78class LLAudioEngine 81class LLAudioEngine
79{ 82{
83 friend class LLAudioChannelOpenAL; // bleh. channel needs some listener methods.
84
80public: 85public:
81 enum LLAudioType 86 enum LLAudioType
82 { 87 {
@@ -91,9 +96,8 @@ public:
91 virtual ~LLAudioEngine(); 96 virtual ~LLAudioEngine();
92 97
93 // initialization/startup/shutdown 98 // initialization/startup/shutdown
94 //virtual BOOL init(); 99 virtual bool init(const S32 num_channels, void *userdata);
95 100 virtual std::string getDriverName(bool verbose) = 0;
96 virtual BOOL init(const S32 num_channels, void *userdata);
97 virtual void shutdown(); 101 virtual void shutdown();
98 102
99 // Used by the mechanics of the engine 103 // Used by the mechanics of the engine
@@ -106,14 +110,14 @@ public:
106 // 110 //
107 // "End user" functionality 111 // "End user" functionality
108 // 112 //
109 virtual BOOL isWindEnabled(); 113 virtual bool isWindEnabled();
110 virtual void enableWind(BOOL state_b); 114 virtual void enableWind(bool state_b);
111 115
112 // Use these for temporarily muting the audio system. 116 // Use these for temporarily muting the audio system.
113 // Does not change buffers, initialization, etc. but 117 // Does not change buffers, initialization, etc. but
114 // stops playing new sounds. 118 // stops playing new sounds.
115 virtual void setMuted(BOOL muted); 119 virtual void setMuted(bool muted);
116 virtual BOOL getMuted() const { return mMuted; } 120 virtual bool getMuted() const { return mMuted; }
117 121
118 F32 getMasterGain(); 122 F32 getMasterGain();
119 void setMasterGain(F32 gain); 123 void setMasterGain(F32 gain);
@@ -137,7 +141,7 @@ public:
137 void triggerSound(const LLUUID &sound_id, const LLUUID& owner_id, const F32 gain, 141 void triggerSound(const LLUUID &sound_id, const LLUUID& owner_id, const F32 gain,
138 const S32 type = LLAudioEngine::AUDIO_TYPE_NONE, 142 const S32 type = LLAudioEngine::AUDIO_TYPE_NONE,
139 const LLVector3d &pos_global = LLVector3d::zero); 143 const LLVector3d &pos_global = LLVector3d::zero);
140 BOOL preloadSound(const LLUUID &id); 144 bool preloadSound(const LLUUID &id);
141 145
142 void addAudioSource(LLAudioSource *asp); 146 void addAudioSource(LLAudioSource *asp);
143 void cleanupAudioSource(LLAudioSource *asp); 147 void cleanupAudioSource(LLAudioSource *asp);
@@ -146,14 +150,16 @@ public:
146 LLAudioData *getAudioData(const LLUUID &audio_uuid); 150 LLAudioData *getAudioData(const LLUUID &audio_uuid);
147 151
148 152
149 virtual void startInternetStream(const std::string& url) = 0; 153 // Internet stream methods
150 virtual void stopInternetStream() = 0; 154 virtual void startInternetStream(const std::string& url);
151 virtual void pauseInternetStream(int pause) = 0; 155 virtual void stopInternetStream();
152 virtual int isInternetStreamPlaying() = 0; 156 virtual void pauseInternetStream(int pause);
153 virtual void getInternetStreamInfo(char* artist, char* title) { artist[0] = 0; title[0] = 0; } 157 virtual void updateInternetStream();
158 virtual int isInternetStreamPlaying();
159 virtual void getInternetStreamInfo(char* artist, char* title);
154 // use a value from 0.0 to 1.0, inclusive 160 // use a value from 0.0 to 1.0, inclusive
155 virtual void setInternetStreamGain(F32 vol) { mInternetStreamGain = vol; } 161 virtual void setInternetStreamGain(F32 vol);
156 virtual const std::string& getInternetStreamURL() { return LLStringUtil::null; } 162 virtual const std::string& getInternetStreamURL();
157 163
158 // For debugging usage 164 // For debugging usage
159 virtual LLVector3 getListenerPos(); 165 virtual LLVector3 getListenerPos();
@@ -162,17 +168,16 @@ public:
162 LLAudioChannel *getFreeChannel(const F32 priority); // Get a free channel or flush an existing one if your priority is higher 168 LLAudioChannel *getFreeChannel(const F32 priority); // Get a free channel or flush an existing one if your priority is higher
163 void cleanupBuffer(LLAudioBuffer *bufferp); 169 void cleanupBuffer(LLAudioBuffer *bufferp);
164 170
165 BOOL hasDecodedFile(const LLUUID &uuid); 171 bool hasDecodedFile(const LLUUID &uuid);
166 BOOL hasLocalFile(const LLUUID &uuid); 172 bool hasLocalFile(const LLUUID &uuid);
167 173
168 BOOL updateBufferForData(LLAudioData *adp, const LLUUID &audio_uuid = LLUUID::null); 174 bool updateBufferForData(LLAudioData *adp, const LLUUID &audio_uuid = LLUUID::null);
169 175
170 176
171 // Asset callback when we're retrieved a sound from the asset server. 177 // Asset callback when we're retrieved a sound from the asset server.
172 void startNextTransfer(); 178 void startNextTransfer();
173 static void assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, void *user_data, S32 result_code, LLExtStat ext_status); 179 static void assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, void *user_data, S32 result_code, LLExtStat ext_status);
174 180
175
176 friend class LLPipeline; // For debugging 181 friend class LLPipeline; // For debugging
177public: 182public:
178 F32 mMaxWindGain; // Hack. Public to set before fade in? 183 F32 mMaxWindGain; // Hack. Public to set before fade in?
@@ -190,11 +195,6 @@ protected:
190 virtual void allocateListener() = 0; 195 virtual void allocateListener() = 0;
191 196
192 197
193 // Internet stream methods
194 virtual void initInternetStream() {}
195 virtual void updateInternetStream() {}
196
197
198 // listener methods 198 // listener methods
199 virtual void setListenerPos(LLVector3 vec); 199 virtual void setListenerPos(LLVector3 vec);
200 virtual void setListenerVelocity(LLVector3 vec); 200 virtual void setListenerVelocity(LLVector3 vec);
@@ -209,13 +209,13 @@ protected:
209protected: 209protected:
210 LLListener *mListenerp; 210 LLListener *mListenerp;
211 211
212 BOOL mMuted; 212 bool mMuted;
213 void* mUserData; 213 void* mUserData;
214 214
215 S32 mLastStatus; 215 S32 mLastStatus;
216 216
217 S32 mNumChannels; 217 S32 mNumChannels;
218 BOOL mEnableWind; 218 bool mEnableWind;
219 219
220 LLUUID mCurrentTransfer; // Audio file currently being transferred by the system 220 LLUUID mCurrentTransfer; // Audio file currently being transferred by the system
221 LLFrameTimer mCurrentTransferTimer; 221 LLFrameTimer mCurrentTransferTimer;
@@ -240,6 +240,7 @@ protected:
240 240
241 // Hack! Internet streams are treated differently from other sources! 241 // Hack! Internet streams are treated differently from other sources!
242 F32 mInternetStreamGain; 242 F32 mInternetStreamGain;
243 std::string mInternetStreamURL;
243 244
244 F32 mNextWindUpdate; 245 F32 mNextWindUpdate;
245 246
@@ -247,6 +248,7 @@ protected:
247 248
248private: 249private:
249 void setDefaults(); 250 void setDefaults();
251 LLMediaBase *mInternetStreamMedia;
250}; 252};
251 253
252 254
@@ -270,24 +272,24 @@ public:
270 272
271 void preload(const LLUUID &audio_id); // Only used for preloading UI sounds, now. 273 void preload(const LLUUID &audio_id); // Only used for preloading UI sounds, now.
272 274
273 void addAudioData(LLAudioData *adp, BOOL set_current = TRUE); 275 void addAudioData(LLAudioData *adp, bool set_current = TRUE);
274 276
275 void setAmbient(const BOOL ambient) { mAmbient = ambient; } 277 void setAmbient(const bool ambient) { mAmbient = ambient; }
276 BOOL isAmbient() const { return mAmbient; } 278 bool isAmbient() const { return mAmbient; }
277 279
278 void setLoop(const BOOL loop) { mLoop = loop; } 280 void setLoop(const bool loop) { mLoop = loop; }
279 BOOL isLoop() const { return mLoop; } 281 bool isLoop() const { return mLoop; }
280 282
281 void setSyncMaster(const BOOL master) { mSyncMaster = master; } 283 void setSyncMaster(const bool master) { mSyncMaster = master; }
282 BOOL isSyncMaster() const { return mSyncMaster; } 284 bool isSyncMaster() const { return mSyncMaster; }
283 285
284 void setSyncSlave(const BOOL slave) { mSyncSlave = slave; } 286 void setSyncSlave(const bool slave) { mSyncSlave = slave; }
285 BOOL isSyncSlave() const { return mSyncSlave; } 287 bool isSyncSlave() const { return mSyncSlave; }
286 288
287 void setQueueSounds(const BOOL queue) { mQueueSounds = queue; } 289 void setQueueSounds(const bool queue) { mQueueSounds = queue; }
288 BOOL isQueueSounds() const { return mQueueSounds; } 290 bool isQueueSounds() const { return mQueueSounds; }
289 291
290 void setPlayedOnce(const BOOL played_once) { mPlayedOnce = played_once; } 292 void setPlayedOnce(const bool played_once) { mPlayedOnce = played_once; }
291 293
292 void setType(S32 type) { mType = type; } 294 void setType(S32 type) { mType = type; }
293 S32 getType() { return mType; } 295 S32 getType() { return mType; }
@@ -302,16 +304,16 @@ public:
302 virtual void setGain(const F32 gain) { mGain = llclamp(gain, 0.f, 1.f); } 304 virtual void setGain(const F32 gain) { mGain = llclamp(gain, 0.f, 1.f); }
303 305
304 const LLUUID &getID() const { return mID; } 306 const LLUUID &getID() const { return mID; }
305 BOOL isDone(); 307 bool isDone();
306 308
307 LLAudioData *getCurrentData(); 309 LLAudioData *getCurrentData();
308 LLAudioData *getQueuedData(); 310 LLAudioData *getQueuedData();
309 LLAudioBuffer *getCurrentBuffer(); 311 LLAudioBuffer *getCurrentBuffer();
310 312
311 BOOL setupChannel(); 313 bool setupChannel();
312 BOOL play(const LLUUID &audio_id); // Start the audio source playing 314 bool play(const LLUUID &audio_id); // Start the audio source playing
313 315
314 BOOL hasPendingPreloads() const; // Has preloads that haven't been done yet 316 bool hasPendingPreloads() const; // Has preloads that haven't been done yet
315 317
316 friend class LLAudioEngine; 318 friend class LLAudioEngine;
317 friend class LLAudioChannel; 319 friend class LLAudioChannel;
@@ -324,12 +326,12 @@ protected:
324 LLUUID mOwnerID; // owner of the object playing the sound 326 LLUUID mOwnerID; // owner of the object playing the sound
325 F32 mPriority; 327 F32 mPriority;
326 F32 mGain; 328 F32 mGain;
327 BOOL mAmbient; 329 bool mAmbient;
328 BOOL mLoop; 330 bool mLoop;
329 BOOL mSyncMaster; 331 bool mSyncMaster;
330 BOOL mSyncSlave; 332 bool mSyncSlave;
331 BOOL mQueueSounds; 333 bool mQueueSounds;
332 BOOL mPlayedOnce; 334 bool mPlayedOnce;
333 S32 mType; 335 S32 mType;
334 LLVector3d mPositionGlobal; 336 LLVector3d mPositionGlobal;
335 LLVector3 mVelocity; 337 LLVector3 mVelocity;
@@ -359,27 +361,27 @@ class LLAudioData
359{ 361{
360public: 362public:
361 LLAudioData(const LLUUID &uuid); 363 LLAudioData(const LLUUID &uuid);
362 BOOL load(); 364 bool load();
363 365
364 LLUUID getID() const { return mID; } 366 LLUUID getID() const { return mID; }
365 LLAudioBuffer *getBuffer() const { return mBufferp; } 367 LLAudioBuffer *getBuffer() const { return mBufferp; }
366 368
367 BOOL hasLocalData() const { return mHasLocalData; } 369 bool hasLocalData() const { return mHasLocalData; }
368 BOOL hasDecodedData() const { return mHasDecodedData; } 370 bool hasDecodedData() const { return mHasDecodedData; }
369 BOOL hasValidData() const { return mHasValidData; } 371 bool hasValidData() const { return mHasValidData; }
370 372
371 void setHasLocalData(const BOOL hld) { mHasLocalData = hld; } 373 void setHasLocalData(const bool hld) { mHasLocalData = hld; }
372 void setHasDecodedData(const BOOL hdd) { mHasDecodedData = hdd; } 374 void setHasDecodedData(const bool hdd) { mHasDecodedData = hdd; }
373 void setHasValidData(const BOOL hvd) { mHasValidData = hvd; } 375 void setHasValidData(const bool hvd) { mHasValidData = hvd; }
374 376
375 friend class LLAudioEngine; // Severe laziness, bad. 377 friend class LLAudioEngine; // Severe laziness, bad.
376 378
377protected: 379protected:
378 LLUUID mID; 380 LLUUID mID;
379 LLAudioBuffer *mBufferp; // If this data is being used by the audio system, a pointer to the buffer will be set here. 381 LLAudioBuffer *mBufferp; // If this data is being used by the audio system, a pointer to the buffer will be set here.
380 BOOL mHasLocalData; 382 bool mHasLocalData;
381 BOOL mHasDecodedData; 383 bool mHasDecodedData;
382 BOOL mHasValidData; 384 bool mHasValidData;
383}; 385};
384 386
385 387
@@ -408,18 +410,18 @@ protected:
408 virtual void play() = 0; 410 virtual void play() = 0;
409 virtual void playSynced(LLAudioChannel *channelp) = 0; 411 virtual void playSynced(LLAudioChannel *channelp) = 0;
410 virtual void cleanup() = 0; 412 virtual void cleanup() = 0;
411 virtual BOOL isPlaying() = 0; 413 virtual bool isPlaying() = 0;
412 void setWaiting(const BOOL waiting) { mWaiting = waiting; } 414 void setWaiting(const bool waiting) { mWaiting = waiting; }
413 BOOL isWaiting() const { return mWaiting; } 415 bool isWaiting() const { return mWaiting; }
414 416
415 virtual BOOL updateBuffer(); // Check to see if the buffer associated with the source changed, and update if necessary. 417 virtual bool updateBuffer(); // Check to see if the buffer associated with the source changed, and update if necessary.
416 virtual void update3DPosition() = 0; 418 virtual void update3DPosition() = 0;
417 virtual void updateLoop() = 0; // Update your loop/completion status, for use by queueing/syncing. 419 virtual void updateLoop() = 0; // Update your loop/completion status, for use by queueing/syncing.
418protected: 420protected:
419 LLAudioSource *mCurrentSourcep; 421 LLAudioSource *mCurrentSourcep;
420 LLAudioBuffer *mCurrentBufferp; 422 LLAudioBuffer *mCurrentBufferp;
421 BOOL mLoopedThisFrame; 423 bool mLoopedThisFrame;
422 BOOL mWaiting; // Waiting for sync. 424 bool mWaiting; // Waiting for sync.
423 F32 mSecondaryGain; 425 F32 mSecondaryGain;
424}; 426};
425 427
@@ -435,14 +437,14 @@ class LLAudioBuffer
435{ 437{
436public: 438public:
437 virtual ~LLAudioBuffer() {}; 439 virtual ~LLAudioBuffer() {};
438 virtual BOOL loadWAV(const std::string& filename) = 0; 440 virtual bool loadWAV(const std::string& filename) = 0;
439 virtual U32 getLength() = 0; 441 virtual U32 getLength() = 0;
440 442
441 friend class LLAudioEngine; 443 friend class LLAudioEngine;
442 friend class LLAudioChannel; 444 friend class LLAudioChannel;
443 friend class LLAudioData; 445 friend class LLAudioData;
444protected: 446protected:
445 BOOL mInUse; 447 bool mInUse;
446 LLAudioData *mAudioDatap; 448 LLAudioData *mAudioDatap;
447 LLFrameTimer mLastUseTimer; 449 LLFrameTimer mLastUseTimer;
448}; 450};