aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llaudio/audioengine.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--linden/indra/llaudio/audioengine.h161
1 files changed, 93 insertions, 68 deletions
diff --git a/linden/indra/llaudio/audioengine.h b/linden/indra/llaudio/audioengine.h
index e38413f..15cb35f 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,14 +80,24 @@ class LLAudioBuffer;
77 80
78class LLAudioEngine 81class LLAudioEngine
79{ 82{
83 friend class LLAudioChannelOpenAL; // bleh. channel needs some listener methods.
84
80public: 85public:
86 enum LLAudioType
87 {
88 AUDIO_TYPE_NONE = 0,
89 AUDIO_TYPE_SFX = 1,
90 AUDIO_TYPE_UI = 2,
91 AUDIO_TYPE_AMBIENT = 3,
92 AUDIO_TYPE_COUNT = 4 // last
93 };
94
81 LLAudioEngine(); 95 LLAudioEngine();
82 virtual ~LLAudioEngine(); 96 virtual ~LLAudioEngine();
83 97
84 // initialization/startup/shutdown 98 // initialization/startup/shutdown
85 //virtual BOOL init(); 99 virtual bool init(const S32 num_channels, void *userdata);
86 100 virtual std::string getDriverName(bool verbose) = 0;
87 virtual BOOL init(const S32 num_channels, void *userdata);
88 virtual void shutdown(); 101 virtual void shutdown();
89 102
90 // Used by the mechanics of the engine 103 // Used by the mechanics of the engine
@@ -97,18 +110,21 @@ public:
97 // 110 //
98 // "End user" functionality 111 // "End user" functionality
99 // 112 //
100 virtual BOOL isWindEnabled(); 113 virtual bool isWindEnabled();
101 virtual void enableWind(BOOL state_b); 114 virtual void enableWind(bool state_b);
102 115
103 // Use these for temporarily muting the audio system. 116 // Use these for temporarily muting the audio system.
104 // Does not change buffers, initialization, etc. but 117 // Does not change buffers, initialization, etc. but
105 // stops playing new sounds. 118 // stops playing new sounds.
106 virtual void setMuted(BOOL muted); 119 virtual void setMuted(bool muted);
107 virtual BOOL getMuted() const { return mMuted; } 120 virtual bool getMuted() const { return mMuted; }
108 121
109 F32 getMasterGain(); 122 F32 getMasterGain();
110 void setMasterGain(F32 gain); 123 void setMasterGain(F32 gain);
111 124
125 F32 getSecondaryGain(S32 type);
126 void setSecondaryGain(S32 type, F32 gain);
127
112 F32 getInternetStreamGain(); 128 F32 getInternetStreamGain();
113 129
114 virtual void setDopplerFactor(F32 factor); 130 virtual void setDopplerFactor(F32 factor);
@@ -122,8 +138,10 @@ public:
122 138
123 // Methods actually related to setting up and removing sounds 139 // Methods actually related to setting up and removing sounds
124 // Owner ID is the owner of the object making the request 140 // Owner ID is the owner of the object making the request
125 void triggerSound(const LLUUID &sound_id, const LLUUID& owner_id, const F32 gain, const LLVector3d &pos_global = LLVector3d::zero); 141 void triggerSound(const LLUUID &sound_id, const LLUUID& owner_id, const F32 gain,
126 BOOL preloadSound(const LLUUID &id); 142 const S32 type = LLAudioEngine::AUDIO_TYPE_NONE,
143 const LLVector3d &pos_global = LLVector3d::zero);
144 bool preloadSound(const LLUUID &id);
127 145
128 void addAudioSource(LLAudioSource *asp); 146 void addAudioSource(LLAudioSource *asp);
129 void cleanupAudioSource(LLAudioSource *asp); 147 void cleanupAudioSource(LLAudioSource *asp);
@@ -132,14 +150,16 @@ public:
132 LLAudioData *getAudioData(const LLUUID &audio_uuid); 150 LLAudioData *getAudioData(const LLUUID &audio_uuid);
133 151
134 152
135 virtual void startInternetStream(const std::string& url) = 0; 153 // Internet stream methods
136 virtual void stopInternetStream() = 0; 154 virtual void startInternetStream(const std::string& url);
137 virtual void pauseInternetStream(int pause) = 0; 155 virtual void stopInternetStream();
138 virtual int isInternetStreamPlaying() = 0; 156 virtual void pauseInternetStream(int pause);
139 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);
140 // use a value from 0.0 to 1.0, inclusive 160 // use a value from 0.0 to 1.0, inclusive
141 virtual void setInternetStreamGain(F32 vol) { mInternetStreamGain = vol; } 161 virtual void setInternetStreamGain(F32 vol);
142 virtual const std::string& getInternetStreamURL() { return LLStringUtil::null; } 162 virtual const std::string& getInternetStreamURL();
143 163
144 // For debugging usage 164 // For debugging usage
145 virtual LLVector3 getListenerPos(); 165 virtual LLVector3 getListenerPos();
@@ -148,17 +168,16 @@ public:
148 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
149 void cleanupBuffer(LLAudioBuffer *bufferp); 169 void cleanupBuffer(LLAudioBuffer *bufferp);
150 170
151 BOOL hasDecodedFile(const LLUUID &uuid); 171 bool hasDecodedFile(const LLUUID &uuid);
152 BOOL hasLocalFile(const LLUUID &uuid); 172 bool hasLocalFile(const LLUUID &uuid);
153 173
154 BOOL updateBufferForData(LLAudioData *adp, const LLUUID &audio_uuid = LLUUID::null); 174 bool updateBufferForData(LLAudioData *adp, const LLUUID &audio_uuid = LLUUID::null);
155 175
156 176
157 // 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.
158 void startNextTransfer(); 178 void startNextTransfer();
159 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);
160 180
161
162 friend class LLPipeline; // For debugging 181 friend class LLPipeline; // For debugging
163public: 182public:
164 F32 mMaxWindGain; // Hack. Public to set before fade in? 183 F32 mMaxWindGain; // Hack. Public to set before fade in?
@@ -176,11 +195,6 @@ protected:
176 virtual void allocateListener() = 0; 195 virtual void allocateListener() = 0;
177 196
178 197
179 // Internet stream methods
180 virtual void initInternetStream() {}
181 virtual void updateInternetStream() {}
182
183
184 // listener methods 198 // listener methods
185 virtual void setListenerPos(LLVector3 vec); 199 virtual void setListenerPos(LLVector3 vec);
186 virtual void setListenerVelocity(LLVector3 vec); 200 virtual void setListenerVelocity(LLVector3 vec);
@@ -195,13 +209,13 @@ protected:
195protected: 209protected:
196 LLListener *mListenerp; 210 LLListener *mListenerp;
197 211
198 BOOL mMuted; 212 bool mMuted;
199 void* mUserData; 213 void* mUserData;
200 214
201 S32 mLastStatus; 215 S32 mLastStatus;
202 216
203 S32 mNumChannels; 217 S32 mNumChannels;
204 BOOL mEnableWind; 218 bool mEnableWind;
205 219
206 LLUUID mCurrentTransfer; // Audio file currently being transferred by the system 220 LLUUID mCurrentTransfer; // Audio file currently being transferred by the system
207 LLFrameTimer mCurrentTransferTimer; 221 LLFrameTimer mCurrentTransferTimer;
@@ -222,9 +236,11 @@ protected:
222 LLAudioBuffer *mBuffers[MAX_BUFFERS]; 236 LLAudioBuffer *mBuffers[MAX_BUFFERS];
223 237
224 F32 mMasterGain; 238 F32 mMasterGain;
239 F32 mSecondaryGain[AUDIO_TYPE_COUNT];
225 240
226 // Hack! Internet streams are treated differently from other sources! 241 // Hack! Internet streams are treated differently from other sources!
227 F32 mInternetStreamGain; 242 F32 mInternetStreamGain;
243 std::string mInternetStreamURL;
228 244
229 F32 mNextWindUpdate; 245 F32 mNextWindUpdate;
230 246
@@ -232,6 +248,7 @@ protected:
232 248
233private: 249private:
234 void setDefaults(); 250 void setDefaults();
251 LLMediaBase *mInternetStreamMedia;
235}; 252};
236 253
237 254
@@ -247,7 +264,7 @@ class LLAudioSource
247public: 264public:
248 // owner_id is the id of the agent responsible for making this sound 265 // owner_id is the id of the agent responsible for making this sound
249 // play, for example, the owner of the object currently playing it 266 // play, for example, the owner of the object currently playing it
250 LLAudioSource(const LLUUID &id, const LLUUID& owner_id, const F32 gain); 267 LLAudioSource(const LLUUID &id, const LLUUID& owner_id, const F32 gain, const S32 type = LLAudioEngine::AUDIO_TYPE_NONE);
251 virtual ~LLAudioSource(); 268 virtual ~LLAudioSource();
252 269
253 virtual void update(); // Update this audio source 270 virtual void update(); // Update this audio source
@@ -255,24 +272,27 @@ public:
255 272
256 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.
257 274
258 void addAudioData(LLAudioData *adp, BOOL set_current = TRUE); 275 void addAudioData(LLAudioData *adp, bool set_current = TRUE);
276
277 void setAmbient(const bool ambient) { mAmbient = ambient; }
278 bool isAmbient() const { return mAmbient; }
259 279
260 void setAmbient(const BOOL ambient) { mAmbient = ambient; } 280 void setLoop(const bool loop) { mLoop = loop; }
261 BOOL isAmbient() const { return mAmbient; } 281 bool isLoop() const { return mLoop; }
262 282
263 void setLoop(const BOOL loop) { mLoop = loop; } 283 void setSyncMaster(const bool master) { mSyncMaster = master; }
264 BOOL isLoop() const { return mLoop; } 284 bool isSyncMaster() const { return mSyncMaster; }
265 285
266 void setSyncMaster(const BOOL master) { mSyncMaster = master; } 286 void setSyncSlave(const bool slave) { mSyncSlave = slave; }
267 BOOL isSyncMaster() const { return mSyncMaster; } 287 bool isSyncSlave() const { return mSyncSlave; }
268 288
269 void setSyncSlave(const BOOL slave) { mSyncSlave = slave; } 289 void setQueueSounds(const bool queue) { mQueueSounds = queue; }
270 BOOL isSyncSlave() const { return mSyncSlave; } 290 bool isQueueSounds() const { return mQueueSounds; }
271 291
272 void setQueueSounds(const BOOL queue) { mQueueSounds = queue; } 292 void setPlayedOnce(const bool played_once) { mPlayedOnce = played_once; }
273 BOOL isQueueSounds() const { return mQueueSounds; }
274 293
275 void setPlayedOnce(const BOOL played_once) { mPlayedOnce = played_once; } 294 void setType(S32 type) { mType = type; }
295 S32 getType() { return mType; }
276 296
277 void setPositionGlobal(const LLVector3d &position_global) { mPositionGlobal = position_global; } 297 void setPositionGlobal(const LLVector3d &position_global) { mPositionGlobal = position_global; }
278 LLVector3d getPositionGlobal() const { return mPositionGlobal; } 298 LLVector3d getPositionGlobal() const { return mPositionGlobal; }
@@ -284,16 +304,16 @@ public:
284 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); }
285 305
286 const LLUUID &getID() const { return mID; } 306 const LLUUID &getID() const { return mID; }
287 BOOL isDone(); 307 bool isDone();
288 308
289 LLAudioData *getCurrentData(); 309 LLAudioData *getCurrentData();
290 LLAudioData *getQueuedData(); 310 LLAudioData *getQueuedData();
291 LLAudioBuffer *getCurrentBuffer(); 311 LLAudioBuffer *getCurrentBuffer();
292 312
293 BOOL setupChannel(); 313 bool setupChannel();
294 BOOL play(const LLUUID &audio_id); // Start the audio source playing 314 bool play(const LLUUID &audio_id); // Start the audio source playing
295 315
296 BOOL hasPendingPreloads() const; // Has preloads that haven't been done yet 316 bool hasPendingPreloads() const; // Has preloads that haven't been done yet
297 317
298 friend class LLAudioEngine; 318 friend class LLAudioEngine;
299 friend class LLAudioChannel; 319 friend class LLAudioChannel;
@@ -306,12 +326,13 @@ protected:
306 LLUUID mOwnerID; // owner of the object playing the sound 326 LLUUID mOwnerID; // owner of the object playing the sound
307 F32 mPriority; 327 F32 mPriority;
308 F32 mGain; 328 F32 mGain;
309 BOOL mAmbient; 329 bool mAmbient;
310 BOOL mLoop; 330 bool mLoop;
311 BOOL mSyncMaster; 331 bool mSyncMaster;
312 BOOL mSyncSlave; 332 bool mSyncSlave;
313 BOOL mQueueSounds; 333 bool mQueueSounds;
314 BOOL mPlayedOnce; 334 bool mPlayedOnce;
335 S32 mType;
315 LLVector3d mPositionGlobal; 336 LLVector3d mPositionGlobal;
316 LLVector3 mVelocity; 337 LLVector3 mVelocity;
317 338
@@ -340,27 +361,27 @@ class LLAudioData
340{ 361{
341public: 362public:
342 LLAudioData(const LLUUID &uuid); 363 LLAudioData(const LLUUID &uuid);
343 BOOL load(); 364 bool load();
344 365
345 LLUUID getID() const { return mID; } 366 LLUUID getID() const { return mID; }
346 LLAudioBuffer *getBuffer() const { return mBufferp; } 367 LLAudioBuffer *getBuffer() const { return mBufferp; }
347 368
348 BOOL hasLocalData() const { return mHasLocalData; } 369 bool hasLocalData() const { return mHasLocalData; }
349 BOOL hasDecodedData() const { return mHasDecodedData; } 370 bool hasDecodedData() const { return mHasDecodedData; }
350 BOOL hasValidData() const { return mHasValidData; } 371 bool hasValidData() const { return mHasValidData; }
351 372
352 void setHasLocalData(const BOOL hld) { mHasLocalData = hld; } 373 void setHasLocalData(const bool hld) { mHasLocalData = hld; }
353 void setHasDecodedData(const BOOL hdd) { mHasDecodedData = hdd; } 374 void setHasDecodedData(const bool hdd) { mHasDecodedData = hdd; }
354 void setHasValidData(const BOOL hvd) { mHasValidData = hvd; } 375 void setHasValidData(const bool hvd) { mHasValidData = hvd; }
355 376
356 friend class LLAudioEngine; // Severe laziness, bad. 377 friend class LLAudioEngine; // Severe laziness, bad.
357 378
358protected: 379protected:
359 LLUUID mID; 380 LLUUID mID;
360 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.
361 BOOL mHasLocalData; 382 bool mHasLocalData;
362 BOOL mHasDecodedData; 383 bool mHasDecodedData;
363 BOOL mHasValidData; 384 bool mHasValidData;
364}; 385};
365 386
366 387
@@ -380,24 +401,28 @@ public:
380 virtual void setSource(LLAudioSource *sourcep); 401 virtual void setSource(LLAudioSource *sourcep);
381 LLAudioSource *getSource() const { return mCurrentSourcep; } 402 LLAudioSource *getSource() const { return mCurrentSourcep; }
382 403
404 void setSecondaryGain(F32 gain) { mSecondaryGain = gain; }
405 F32 getSecondaryGain() { return mSecondaryGain; }
406
383 friend class LLAudioEngine; 407 friend class LLAudioEngine;
384 friend class LLAudioSource; 408 friend class LLAudioSource;
385protected: 409protected:
386 virtual void play() = 0; 410 virtual void play() = 0;
387 virtual void playSynced(LLAudioChannel *channelp) = 0; 411 virtual void playSynced(LLAudioChannel *channelp) = 0;
388 virtual void cleanup() = 0; 412 virtual void cleanup() = 0;
389 virtual BOOL isPlaying() = 0; 413 virtual bool isPlaying() = 0;
390 void setWaiting(const BOOL waiting) { mWaiting = waiting; } 414 void setWaiting(const bool waiting) { mWaiting = waiting; }
391 BOOL isWaiting() const { return mWaiting; } 415 bool isWaiting() const { return mWaiting; }
392 416
393 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.
394 virtual void update3DPosition() = 0; 418 virtual void update3DPosition() = 0;
395 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.
396protected: 420protected:
397 LLAudioSource *mCurrentSourcep; 421 LLAudioSource *mCurrentSourcep;
398 LLAudioBuffer *mCurrentBufferp; 422 LLAudioBuffer *mCurrentBufferp;
399 BOOL mLoopedThisFrame; 423 bool mLoopedThisFrame;
400 BOOL mWaiting; // Waiting for sync. 424 bool mWaiting; // Waiting for sync.
425 F32 mSecondaryGain;
401}; 426};
402 427
403 428
@@ -412,14 +437,14 @@ class LLAudioBuffer
412{ 437{
413public: 438public:
414 virtual ~LLAudioBuffer() {}; 439 virtual ~LLAudioBuffer() {};
415 virtual BOOL loadWAV(const std::string& filename) = 0; 440 virtual bool loadWAV(const std::string& filename) = 0;
416 virtual U32 getLength() = 0; 441 virtual U32 getLength() = 0;
417 442
418 friend class LLAudioEngine; 443 friend class LLAudioEngine;
419 friend class LLAudioChannel; 444 friend class LLAudioChannel;
420 friend class LLAudioData; 445 friend class LLAudioData;
421protected: 446protected:
422 BOOL mInUse; 447 bool mInUse;
423 LLAudioData *mAudioDatap; 448 LLAudioData *mAudioDatap;
424 LLFrameTimer mLastUseTimer; 449 LLFrameTimer mLastUseTimer;
425}; 450};