diff options
Diffstat (limited to 'linden/indra/llaudio/audioengine.h')
-rw-r--r-- | linden/indra/llaudio/audioengine.h | 130 |
1 files changed, 64 insertions, 66 deletions
diff --git a/linden/indra/llaudio/audioengine.h b/linden/indra/llaudio/audioengine.h index e38413f..94134f5 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 | ||
48 | class LLMediaBase; | ||
49 | |||
48 | const F32 LL_WIND_UPDATE_INTERVAL = 0.1f; | 50 | const F32 LL_WIND_UPDATE_INTERVAL = 0.1f; |
49 | const F32 LL_ROLLOFF_MULTIPLIER_UNDER_WATER = 5.f; // How much sounds are weaker under water | 51 | const F32 LL_ROLLOFF_MULTIPLIER_UNDER_WATER = 5.f; // How much sounds are weaker under water |
50 | const F32 LL_WIND_UNDERWATER_CENTER_FREQ = 20.f; | 52 | const F32 LL_WIND_UNDERWATER_CENTER_FREQ = 20.f; |
@@ -82,9 +84,7 @@ public: | |||
82 | virtual ~LLAudioEngine(); | 84 | virtual ~LLAudioEngine(); |
83 | 85 | ||
84 | // initialization/startup/shutdown | 86 | // initialization/startup/shutdown |
85 | //virtual BOOL init(); | 87 | virtual bool init(const S32 num_channels, void *userdata); |
86 | |||
87 | virtual BOOL init(const S32 num_channels, void *userdata); | ||
88 | virtual void shutdown(); | 88 | virtual void shutdown(); |
89 | 89 | ||
90 | // Used by the mechanics of the engine | 90 | // Used by the mechanics of the engine |
@@ -97,14 +97,14 @@ public: | |||
97 | // | 97 | // |
98 | // "End user" functionality | 98 | // "End user" functionality |
99 | // | 99 | // |
100 | virtual BOOL isWindEnabled(); | 100 | virtual bool isWindEnabled(); |
101 | virtual void enableWind(BOOL state_b); | 101 | virtual void enableWind(bool state_b); |
102 | 102 | ||
103 | // Use these for temporarily muting the audio system. | 103 | // Use these for temporarily muting the audio system. |
104 | // Does not change buffers, initialization, etc. but | 104 | // Does not change buffers, initialization, etc. but |
105 | // stops playing new sounds. | 105 | // stops playing new sounds. |
106 | virtual void setMuted(BOOL muted); | 106 | virtual void setMuted(bool muted); |
107 | virtual BOOL getMuted() const { return mMuted; } | 107 | virtual bool getMuted() const { return mMuted; } |
108 | 108 | ||
109 | F32 getMasterGain(); | 109 | F32 getMasterGain(); |
110 | void setMasterGain(F32 gain); | 110 | void setMasterGain(F32 gain); |
@@ -123,7 +123,7 @@ public: | |||
123 | // Methods actually related to setting up and removing sounds | 123 | // Methods actually related to setting up and removing sounds |
124 | // Owner ID is the owner of the object making the request | 124 | // 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); | 125 | void triggerSound(const LLUUID &sound_id, const LLUUID& owner_id, const F32 gain, const LLVector3d &pos_global = LLVector3d::zero); |
126 | BOOL preloadSound(const LLUUID &id); | 126 | bool preloadSound(const LLUUID &id); |
127 | 127 | ||
128 | void addAudioSource(LLAudioSource *asp); | 128 | void addAudioSource(LLAudioSource *asp); |
129 | void cleanupAudioSource(LLAudioSource *asp); | 129 | void cleanupAudioSource(LLAudioSource *asp); |
@@ -132,14 +132,16 @@ public: | |||
132 | LLAudioData *getAudioData(const LLUUID &audio_uuid); | 132 | LLAudioData *getAudioData(const LLUUID &audio_uuid); |
133 | 133 | ||
134 | 134 | ||
135 | virtual void startInternetStream(const std::string& url) = 0; | 135 | // Internet stream methods |
136 | virtual void stopInternetStream() = 0; | 136 | virtual void startInternetStream(const std::string& url); |
137 | virtual void pauseInternetStream(int pause) = 0; | 137 | virtual void stopInternetStream(); |
138 | virtual int isInternetStreamPlaying() = 0; | 138 | virtual void pauseInternetStream(int pause); |
139 | virtual void getInternetStreamInfo(char* artist, char* title) { artist[0] = 0; title[0] = 0; } | 139 | virtual void updateInternetStream(); |
140 | virtual int isInternetStreamPlaying(); | ||
141 | virtual void getInternetStreamInfo(char* artist, char* title); | ||
140 | // use a value from 0.0 to 1.0, inclusive | 142 | // use a value from 0.0 to 1.0, inclusive |
141 | virtual void setInternetStreamGain(F32 vol) { mInternetStreamGain = vol; } | 143 | virtual void setInternetStreamGain(F32 vol); |
142 | virtual const std::string& getInternetStreamURL() { return LLStringUtil::null; } | 144 | virtual const std::string& getInternetStreamURL(); |
143 | 145 | ||
144 | // For debugging usage | 146 | // For debugging usage |
145 | virtual LLVector3 getListenerPos(); | 147 | virtual LLVector3 getListenerPos(); |
@@ -148,17 +150,16 @@ public: | |||
148 | LLAudioChannel *getFreeChannel(const F32 priority); // Get a free channel or flush an existing one if your priority is higher | 150 | LLAudioChannel *getFreeChannel(const F32 priority); // Get a free channel or flush an existing one if your priority is higher |
149 | void cleanupBuffer(LLAudioBuffer *bufferp); | 151 | void cleanupBuffer(LLAudioBuffer *bufferp); |
150 | 152 | ||
151 | BOOL hasDecodedFile(const LLUUID &uuid); | 153 | bool hasDecodedFile(const LLUUID &uuid); |
152 | BOOL hasLocalFile(const LLUUID &uuid); | 154 | bool hasLocalFile(const LLUUID &uuid); |
153 | 155 | ||
154 | BOOL updateBufferForData(LLAudioData *adp, const LLUUID &audio_uuid = LLUUID::null); | 156 | bool updateBufferForData(LLAudioData *adp, const LLUUID &audio_uuid = LLUUID::null); |
155 | 157 | ||
156 | 158 | ||
157 | // Asset callback when we're retrieved a sound from the asset server. | 159 | // Asset callback when we're retrieved a sound from the asset server. |
158 | void startNextTransfer(); | 160 | void startNextTransfer(); |
159 | static void assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, void *user_data, S32 result_code, LLExtStat ext_status); | 161 | static void assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::EType type, void *user_data, S32 result_code, LLExtStat ext_status); |
160 | 162 | ||
161 | |||
162 | friend class LLPipeline; // For debugging | 163 | friend class LLPipeline; // For debugging |
163 | public: | 164 | public: |
164 | F32 mMaxWindGain; // Hack. Public to set before fade in? | 165 | F32 mMaxWindGain; // Hack. Public to set before fade in? |
@@ -176,11 +177,6 @@ protected: | |||
176 | virtual void allocateListener() = 0; | 177 | virtual void allocateListener() = 0; |
177 | 178 | ||
178 | 179 | ||
179 | // Internet stream methods | ||
180 | virtual void initInternetStream() {} | ||
181 | virtual void updateInternetStream() {} | ||
182 | |||
183 | |||
184 | // listener methods | 180 | // listener methods |
185 | virtual void setListenerPos(LLVector3 vec); | 181 | virtual void setListenerPos(LLVector3 vec); |
186 | virtual void setListenerVelocity(LLVector3 vec); | 182 | virtual void setListenerVelocity(LLVector3 vec); |
@@ -195,13 +191,13 @@ protected: | |||
195 | protected: | 191 | protected: |
196 | LLListener *mListenerp; | 192 | LLListener *mListenerp; |
197 | 193 | ||
198 | BOOL mMuted; | 194 | bool mMuted; |
199 | void* mUserData; | 195 | void* mUserData; |
200 | 196 | ||
201 | S32 mLastStatus; | 197 | S32 mLastStatus; |
202 | 198 | ||
203 | S32 mNumChannels; | 199 | S32 mNumChannels; |
204 | BOOL mEnableWind; | 200 | bool mEnableWind; |
205 | 201 | ||
206 | LLUUID mCurrentTransfer; // Audio file currently being transferred by the system | 202 | LLUUID mCurrentTransfer; // Audio file currently being transferred by the system |
207 | LLFrameTimer mCurrentTransferTimer; | 203 | LLFrameTimer mCurrentTransferTimer; |
@@ -225,6 +221,7 @@ protected: | |||
225 | 221 | ||
226 | // Hack! Internet streams are treated differently from other sources! | 222 | // Hack! Internet streams are treated differently from other sources! |
227 | F32 mInternetStreamGain; | 223 | F32 mInternetStreamGain; |
224 | std::string mInternetStreamURL; | ||
228 | 225 | ||
229 | F32 mNextWindUpdate; | 226 | F32 mNextWindUpdate; |
230 | 227 | ||
@@ -232,6 +229,7 @@ protected: | |||
232 | 229 | ||
233 | private: | 230 | private: |
234 | void setDefaults(); | 231 | void setDefaults(); |
232 | LLMediaBase *mInternetStreamMedia; | ||
235 | }; | 233 | }; |
236 | 234 | ||
237 | 235 | ||
@@ -255,24 +253,24 @@ public: | |||
255 | 253 | ||
256 | void preload(const LLUUID &audio_id); // Only used for preloading UI sounds, now. | 254 | void preload(const LLUUID &audio_id); // Only used for preloading UI sounds, now. |
257 | 255 | ||
258 | void addAudioData(LLAudioData *adp, BOOL set_current = TRUE); | 256 | void addAudioData(LLAudioData *adp, bool set_current = TRUE); |
259 | 257 | ||
260 | void setAmbient(const BOOL ambient) { mAmbient = ambient; } | 258 | void setAmbient(const bool ambient) { mAmbient = ambient; } |
261 | BOOL isAmbient() const { return mAmbient; } | 259 | bool isAmbient() const { return mAmbient; } |
262 | 260 | ||
263 | void setLoop(const BOOL loop) { mLoop = loop; } | 261 | void setLoop(const bool loop) { mLoop = loop; } |
264 | BOOL isLoop() const { return mLoop; } | 262 | bool isLoop() const { return mLoop; } |
265 | 263 | ||
266 | void setSyncMaster(const BOOL master) { mSyncMaster = master; } | 264 | void setSyncMaster(const bool master) { mSyncMaster = master; } |
267 | BOOL isSyncMaster() const { return mSyncMaster; } | 265 | bool isSyncMaster() const { return mSyncMaster; } |
268 | 266 | ||
269 | void setSyncSlave(const BOOL slave) { mSyncSlave = slave; } | 267 | void setSyncSlave(const bool slave) { mSyncSlave = slave; } |
270 | BOOL isSyncSlave() const { return mSyncSlave; } | 268 | bool isSyncSlave() const { return mSyncSlave; } |
271 | 269 | ||
272 | void setQueueSounds(const BOOL queue) { mQueueSounds = queue; } | 270 | void setQueueSounds(const bool queue) { mQueueSounds = queue; } |
273 | BOOL isQueueSounds() const { return mQueueSounds; } | 271 | bool isQueueSounds() const { return mQueueSounds; } |
274 | 272 | ||
275 | void setPlayedOnce(const BOOL played_once) { mPlayedOnce = played_once; } | 273 | void setPlayedOnce(const bool played_once) { mPlayedOnce = played_once; } |
276 | 274 | ||
277 | void setPositionGlobal(const LLVector3d &position_global) { mPositionGlobal = position_global; } | 275 | void setPositionGlobal(const LLVector3d &position_global) { mPositionGlobal = position_global; } |
278 | LLVector3d getPositionGlobal() const { return mPositionGlobal; } | 276 | LLVector3d getPositionGlobal() const { return mPositionGlobal; } |
@@ -284,16 +282,16 @@ public: | |||
284 | virtual void setGain(const F32 gain) { mGain = llclamp(gain, 0.f, 1.f); } | 282 | virtual void setGain(const F32 gain) { mGain = llclamp(gain, 0.f, 1.f); } |
285 | 283 | ||
286 | const LLUUID &getID() const { return mID; } | 284 | const LLUUID &getID() const { return mID; } |
287 | BOOL isDone(); | 285 | bool isDone(); |
288 | 286 | ||
289 | LLAudioData *getCurrentData(); | 287 | LLAudioData *getCurrentData(); |
290 | LLAudioData *getQueuedData(); | 288 | LLAudioData *getQueuedData(); |
291 | LLAudioBuffer *getCurrentBuffer(); | 289 | LLAudioBuffer *getCurrentBuffer(); |
292 | 290 | ||
293 | BOOL setupChannel(); | 291 | bool setupChannel(); |
294 | BOOL play(const LLUUID &audio_id); // Start the audio source playing | 292 | bool play(const LLUUID &audio_id); // Start the audio source playing |
295 | 293 | ||
296 | BOOL hasPendingPreloads() const; // Has preloads that haven't been done yet | 294 | bool hasPendingPreloads() const; // Has preloads that haven't been done yet |
297 | 295 | ||
298 | friend class LLAudioEngine; | 296 | friend class LLAudioEngine; |
299 | friend class LLAudioChannel; | 297 | friend class LLAudioChannel; |
@@ -306,12 +304,12 @@ protected: | |||
306 | LLUUID mOwnerID; // owner of the object playing the sound | 304 | LLUUID mOwnerID; // owner of the object playing the sound |
307 | F32 mPriority; | 305 | F32 mPriority; |
308 | F32 mGain; | 306 | F32 mGain; |
309 | BOOL mAmbient; | 307 | bool mAmbient; |
310 | BOOL mLoop; | 308 | bool mLoop; |
311 | BOOL mSyncMaster; | 309 | bool mSyncMaster; |
312 | BOOL mSyncSlave; | 310 | bool mSyncSlave; |
313 | BOOL mQueueSounds; | 311 | bool mQueueSounds; |
314 | BOOL mPlayedOnce; | 312 | bool mPlayedOnce; |
315 | LLVector3d mPositionGlobal; | 313 | LLVector3d mPositionGlobal; |
316 | LLVector3 mVelocity; | 314 | LLVector3 mVelocity; |
317 | 315 | ||
@@ -340,27 +338,27 @@ class LLAudioData | |||
340 | { | 338 | { |
341 | public: | 339 | public: |
342 | LLAudioData(const LLUUID &uuid); | 340 | LLAudioData(const LLUUID &uuid); |
343 | BOOL load(); | 341 | bool load(); |
344 | 342 | ||
345 | LLUUID getID() const { return mID; } | 343 | LLUUID getID() const { return mID; } |
346 | LLAudioBuffer *getBuffer() const { return mBufferp; } | 344 | LLAudioBuffer *getBuffer() const { return mBufferp; } |
347 | 345 | ||
348 | BOOL hasLocalData() const { return mHasLocalData; } | 346 | bool hasLocalData() const { return mHasLocalData; } |
349 | BOOL hasDecodedData() const { return mHasDecodedData; } | 347 | bool hasDecodedData() const { return mHasDecodedData; } |
350 | BOOL hasValidData() const { return mHasValidData; } | 348 | bool hasValidData() const { return mHasValidData; } |
351 | 349 | ||
352 | void setHasLocalData(const BOOL hld) { mHasLocalData = hld; } | 350 | void setHasLocalData(const bool hld) { mHasLocalData = hld; } |
353 | void setHasDecodedData(const BOOL hdd) { mHasDecodedData = hdd; } | 351 | void setHasDecodedData(const bool hdd) { mHasDecodedData = hdd; } |
354 | void setHasValidData(const BOOL hvd) { mHasValidData = hvd; } | 352 | void setHasValidData(const bool hvd) { mHasValidData = hvd; } |
355 | 353 | ||
356 | friend class LLAudioEngine; // Severe laziness, bad. | 354 | friend class LLAudioEngine; // Severe laziness, bad. |
357 | 355 | ||
358 | protected: | 356 | protected: |
359 | LLUUID mID; | 357 | LLUUID mID; |
360 | LLAudioBuffer *mBufferp; // If this data is being used by the audio system, a pointer to the buffer will be set here. | 358 | LLAudioBuffer *mBufferp; // If this data is being used by the audio system, a pointer to the buffer will be set here. |
361 | BOOL mHasLocalData; | 359 | bool mHasLocalData; |
362 | BOOL mHasDecodedData; | 360 | bool mHasDecodedData; |
363 | BOOL mHasValidData; | 361 | bool mHasValidData; |
364 | }; | 362 | }; |
365 | 363 | ||
366 | 364 | ||
@@ -386,18 +384,18 @@ protected: | |||
386 | virtual void play() = 0; | 384 | virtual void play() = 0; |
387 | virtual void playSynced(LLAudioChannel *channelp) = 0; | 385 | virtual void playSynced(LLAudioChannel *channelp) = 0; |
388 | virtual void cleanup() = 0; | 386 | virtual void cleanup() = 0; |
389 | virtual BOOL isPlaying() = 0; | 387 | virtual bool isPlaying() = 0; |
390 | void setWaiting(const BOOL waiting) { mWaiting = waiting; } | 388 | void setWaiting(const bool waiting) { mWaiting = waiting; } |
391 | BOOL isWaiting() const { return mWaiting; } | 389 | bool isWaiting() const { return mWaiting; } |
392 | 390 | ||
393 | virtual BOOL updateBuffer(); // Check to see if the buffer associated with the source changed, and update if necessary. | 391 | virtual bool updateBuffer(); // Check to see if the buffer associated with the source changed, and update if necessary. |
394 | virtual void update3DPosition() = 0; | 392 | virtual void update3DPosition() = 0; |
395 | virtual void updateLoop() = 0; // Update your loop/completion status, for use by queueing/syncing. | 393 | virtual void updateLoop() = 0; // Update your loop/completion status, for use by queueing/syncing. |
396 | protected: | 394 | protected: |
397 | LLAudioSource *mCurrentSourcep; | 395 | LLAudioSource *mCurrentSourcep; |
398 | LLAudioBuffer *mCurrentBufferp; | 396 | LLAudioBuffer *mCurrentBufferp; |
399 | BOOL mLoopedThisFrame; | 397 | bool mLoopedThisFrame; |
400 | BOOL mWaiting; // Waiting for sync. | 398 | bool mWaiting; // Waiting for sync. |
401 | }; | 399 | }; |
402 | 400 | ||
403 | 401 | ||
@@ -412,14 +410,14 @@ class LLAudioBuffer | |||
412 | { | 410 | { |
413 | public: | 411 | public: |
414 | virtual ~LLAudioBuffer() {}; | 412 | virtual ~LLAudioBuffer() {}; |
415 | virtual BOOL loadWAV(const std::string& filename) = 0; | 413 | virtual bool loadWAV(const std::string& filename) = 0; |
416 | virtual U32 getLength() = 0; | 414 | virtual U32 getLength() = 0; |
417 | 415 | ||
418 | friend class LLAudioEngine; | 416 | friend class LLAudioEngine; |
419 | friend class LLAudioChannel; | 417 | friend class LLAudioChannel; |
420 | friend class LLAudioData; | 418 | friend class LLAudioData; |
421 | protected: | 419 | protected: |
422 | BOOL mInUse; | 420 | bool mInUse; |
423 | LLAudioData *mAudioDatap; | 421 | LLAudioData *mAudioDatap; |
424 | LLFrameTimer mLastUseTimer; | 422 | LLFrameTimer mLastUseTimer; |
425 | }; | 423 | }; |