diff options
author | Jacek Antonelli | 2008-12-01 17:39:58 -0600 |
---|---|---|
committer | Jacek Antonelli | 2008-12-01 17:40:06 -0600 |
commit | 7abecb48babe6a6f09bf6692ba55076546cfced9 (patch) | |
tree | 8d18a88513fb97adf32c10aae78f4be1984942db /linden/indra/llaudio | |
parent | Second Life viewer sources 1.21.6 (diff) | |
download | meta-impy-7abecb48babe6a6f09bf6692ba55076546cfced9.zip meta-impy-7abecb48babe6a6f09bf6692ba55076546cfced9.tar.gz meta-impy-7abecb48babe6a6f09bf6692ba55076546cfced9.tar.bz2 meta-impy-7abecb48babe6a6f09bf6692ba55076546cfced9.tar.xz |
Second Life viewer sources 1.22.0-RC
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llaudio/CMakeLists.txt | 7 | ||||
-rw-r--r-- | linden/indra/llaudio/audioengine.cpp | 33 | ||||
-rw-r--r-- | linden/indra/llaudio/audioengine.h | 27 | ||||
-rw-r--r-- | linden/indra/llaudio/audioengine_fmod.cpp | 2 |
4 files changed, 62 insertions, 7 deletions
diff --git a/linden/indra/llaudio/CMakeLists.txt b/linden/indra/llaudio/CMakeLists.txt index b662023..ebedcab 100644 --- a/linden/indra/llaudio/CMakeLists.txt +++ b/linden/indra/llaudio/CMakeLists.txt | |||
@@ -65,3 +65,10 @@ set_source_files_properties(${llaudio_HEADER_FILES} | |||
65 | list(APPEND llaudio_SOURCE_FILES ${llaudio_HEADER_FILES}) | 65 | list(APPEND llaudio_SOURCE_FILES ${llaudio_HEADER_FILES}) |
66 | 66 | ||
67 | add_library (llaudio ${llaudio_SOURCE_FILES}) | 67 | add_library (llaudio ${llaudio_SOURCE_FILES}) |
68 | target_link_libraries( | ||
69 | llaudio | ||
70 | ${VORBISENC_LIBRARIES} | ||
71 | ${VORBISFILE_LIBRARIES} | ||
72 | ${VORBIS_LIBRARIES} | ||
73 | ${OGG_LIBRARIES} | ||
74 | ) | ||
diff --git a/linden/indra/llaudio/audioengine.cpp b/linden/indra/llaudio/audioengine.cpp index 5dd5b28..298ab1d 100644 --- a/linden/indra/llaudio/audioengine.cpp +++ b/linden/indra/llaudio/audioengine.cpp | |||
@@ -96,6 +96,9 @@ void LLAudioEngine::setDefaults() | |||
96 | mMasterGain = 1.f; | 96 | mMasterGain = 1.f; |
97 | mInternetStreamGain = 0.125f; | 97 | mInternetStreamGain = 0.125f; |
98 | mNextWindUpdate = 0.f; | 98 | mNextWindUpdate = 0.f; |
99 | |||
100 | for (U32 i = 0; i < LLAudioEngine::AUDIO_TYPE_COUNT; i++) | ||
101 | mSecondaryGain[i] = 1.0f; | ||
99 | } | 102 | } |
100 | 103 | ||
101 | 104 | ||
@@ -167,6 +170,13 @@ void LLAudioEngine::updateChannels() | |||
167 | { | 170 | { |
168 | if (mChannels[i]) | 171 | if (mChannels[i]) |
169 | { | 172 | { |
173 | // set secondary gain if type is available | ||
174 | LLAudioSource* source = mChannels[i]->getSource(); | ||
175 | if (source) | ||
176 | { | ||
177 | mChannels[i]->setSecondaryGain(mSecondaryGain[source->getType()]); | ||
178 | } | ||
179 | |||
170 | mChannels[i]->updateBuffer(); | 180 | mChannels[i]->updateBuffer(); |
171 | mChannels[i]->update3DPosition(); | 181 | mChannels[i]->update3DPosition(); |
172 | mChannels[i]->updateLoop(); | 182 | mChannels[i]->updateLoop(); |
@@ -643,6 +653,18 @@ F32 LLAudioEngine::getMasterGain() | |||
643 | return mMasterGain; | 653 | return mMasterGain; |
644 | } | 654 | } |
645 | 655 | ||
656 | void LLAudioEngine::setSecondaryGain(S32 type, F32 gain) | ||
657 | { | ||
658 | llassert(type < LLAudioEngine::AUDIO_TYPE_COUNT); | ||
659 | |||
660 | mSecondaryGain[type] = gain; | ||
661 | } | ||
662 | |||
663 | F32 LLAudioEngine::getSecondaryGain(S32 type) | ||
664 | { | ||
665 | return mSecondaryGain[type]; | ||
666 | } | ||
667 | |||
646 | F32 LLAudioEngine::getInternetStreamGain() | 668 | F32 LLAudioEngine::getInternetStreamGain() |
647 | { | 669 | { |
648 | return mInternetStreamGain; | 670 | return mInternetStreamGain; |
@@ -718,7 +740,8 @@ F64 LLAudioEngine::mapWindVecToPan(LLVector3 wind_vec) | |||
718 | } | 740 | } |
719 | 741 | ||
720 | 742 | ||
721 | void LLAudioEngine::triggerSound(const LLUUID &audio_uuid, const LLUUID& owner_id, const F32 gain, const LLVector3d &pos_global) | 743 | void LLAudioEngine::triggerSound(const LLUUID &audio_uuid, const LLUUID& owner_id, const F32 gain, |
744 | const S32 type, const LLVector3d &pos_global) | ||
722 | { | 745 | { |
723 | // Create a new source (since this can't be associated with an existing source. | 746 | // Create a new source (since this can't be associated with an existing source. |
724 | //llinfos << "Localized: " << audio_uuid << llendl; | 747 | //llinfos << "Localized: " << audio_uuid << llendl; |
@@ -731,7 +754,7 @@ void LLAudioEngine::triggerSound(const LLUUID &audio_uuid, const LLUUID& owner_i | |||
731 | LLUUID source_id; | 754 | LLUUID source_id; |
732 | source_id.generate(); | 755 | source_id.generate(); |
733 | 756 | ||
734 | LLAudioSource *asp = new LLAudioSource(source_id, owner_id, gain); | 757 | LLAudioSource *asp = new LLAudioSource(source_id, owner_id, gain, type); |
735 | gAudiop->addAudioSource(asp); | 758 | gAudiop->addAudioSource(asp); |
736 | if (pos_global.isExactlyZero()) | 759 | if (pos_global.isExactlyZero()) |
737 | { | 760 | { |
@@ -1180,11 +1203,12 @@ void LLAudioEngine::assetCallback(LLVFS *vfs, const LLUUID &uuid, LLAssetType::E | |||
1180 | // | 1203 | // |
1181 | 1204 | ||
1182 | 1205 | ||
1183 | LLAudioSource::LLAudioSource(const LLUUID& id, const LLUUID& owner_id, const F32 gain) | 1206 | LLAudioSource::LLAudioSource(const LLUUID& id, const LLUUID& owner_id, const F32 gain, const S32 type) |
1184 | : mID(id), | 1207 | : mID(id), |
1185 | mOwnerID(owner_id), | 1208 | mOwnerID(owner_id), |
1186 | mPriority(0.f), | 1209 | mPriority(0.f), |
1187 | mGain(gain), | 1210 | mGain(gain), |
1211 | mType(type), | ||
1188 | mAmbient(FALSE), | 1212 | mAmbient(FALSE), |
1189 | mLoop(FALSE), | 1213 | mLoop(FALSE), |
1190 | mSyncMaster(FALSE), | 1214 | mSyncMaster(FALSE), |
@@ -1515,7 +1539,8 @@ LLAudioChannel::LLAudioChannel() : | |||
1515 | mCurrentSourcep(NULL), | 1539 | mCurrentSourcep(NULL), |
1516 | mCurrentBufferp(NULL), | 1540 | mCurrentBufferp(NULL), |
1517 | mLoopedThisFrame(FALSE), | 1541 | mLoopedThisFrame(FALSE), |
1518 | mWaiting(FALSE) | 1542 | mWaiting(FALSE), |
1543 | mSecondaryGain(1.0f) | ||
1519 | { | 1544 | { |
1520 | } | 1545 | } |
1521 | 1546 | ||
diff --git a/linden/indra/llaudio/audioengine.h b/linden/indra/llaudio/audioengine.h index e38413f..b8153a3 100644 --- a/linden/indra/llaudio/audioengine.h +++ b/linden/indra/llaudio/audioengine.h | |||
@@ -78,6 +78,15 @@ class LLAudioBuffer; | |||
78 | class LLAudioEngine | 78 | class LLAudioEngine |
79 | { | 79 | { |
80 | public: | 80 | public: |
81 | enum LLAudioType | ||
82 | { | ||
83 | AUDIO_TYPE_NONE = 0, | ||
84 | AUDIO_TYPE_SFX = 1, | ||
85 | AUDIO_TYPE_UI = 2, | ||
86 | AUDIO_TYPE_AMBIENT = 3, | ||
87 | AUDIO_TYPE_COUNT = 4 // last | ||
88 | }; | ||
89 | |||
81 | LLAudioEngine(); | 90 | LLAudioEngine(); |
82 | virtual ~LLAudioEngine(); | 91 | virtual ~LLAudioEngine(); |
83 | 92 | ||
@@ -109,6 +118,9 @@ public: | |||
109 | F32 getMasterGain(); | 118 | F32 getMasterGain(); |
110 | void setMasterGain(F32 gain); | 119 | void setMasterGain(F32 gain); |
111 | 120 | ||
121 | F32 getSecondaryGain(S32 type); | ||
122 | void setSecondaryGain(S32 type, F32 gain); | ||
123 | |||
112 | F32 getInternetStreamGain(); | 124 | F32 getInternetStreamGain(); |
113 | 125 | ||
114 | virtual void setDopplerFactor(F32 factor); | 126 | virtual void setDopplerFactor(F32 factor); |
@@ -122,7 +134,9 @@ public: | |||
122 | 134 | ||
123 | // Methods actually related to setting up and removing sounds | 135 | // Methods actually related to setting up and removing sounds |
124 | // Owner ID is the owner of the object making the request | 136 | // 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); | 137 | void triggerSound(const LLUUID &sound_id, const LLUUID& owner_id, const F32 gain, |
138 | const S32 type = LLAudioEngine::AUDIO_TYPE_NONE, | ||
139 | const LLVector3d &pos_global = LLVector3d::zero); | ||
126 | BOOL preloadSound(const LLUUID &id); | 140 | BOOL preloadSound(const LLUUID &id); |
127 | 141 | ||
128 | void addAudioSource(LLAudioSource *asp); | 142 | void addAudioSource(LLAudioSource *asp); |
@@ -222,6 +236,7 @@ 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; |
@@ -247,7 +262,7 @@ class LLAudioSource | |||
247 | public: | 262 | public: |
248 | // owner_id is the id of the agent responsible for making this sound | 263 | // 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 | 264 | // play, for example, the owner of the object currently playing it |
250 | LLAudioSource(const LLUUID &id, const LLUUID& owner_id, const F32 gain); | 265 | LLAudioSource(const LLUUID &id, const LLUUID& owner_id, const F32 gain, const S32 type = LLAudioEngine::AUDIO_TYPE_NONE); |
251 | virtual ~LLAudioSource(); | 266 | virtual ~LLAudioSource(); |
252 | 267 | ||
253 | virtual void update(); // Update this audio source | 268 | virtual void update(); // Update this audio source |
@@ -274,6 +289,9 @@ public: | |||
274 | 289 | ||
275 | void setPlayedOnce(const BOOL played_once) { mPlayedOnce = played_once; } | 290 | void setPlayedOnce(const BOOL played_once) { mPlayedOnce = played_once; } |
276 | 291 | ||
292 | void setType(S32 type) { mType = type; } | ||
293 | S32 getType() { return mType; } | ||
294 | |||
277 | void setPositionGlobal(const LLVector3d &position_global) { mPositionGlobal = position_global; } | 295 | void setPositionGlobal(const LLVector3d &position_global) { mPositionGlobal = position_global; } |
278 | LLVector3d getPositionGlobal() const { return mPositionGlobal; } | 296 | LLVector3d getPositionGlobal() const { return mPositionGlobal; } |
279 | LLVector3 getVelocity() const { return mVelocity; } | 297 | LLVector3 getVelocity() const { return mVelocity; } |
@@ -312,6 +330,7 @@ protected: | |||
312 | BOOL mSyncSlave; | 330 | BOOL mSyncSlave; |
313 | BOOL mQueueSounds; | 331 | BOOL mQueueSounds; |
314 | BOOL mPlayedOnce; | 332 | BOOL mPlayedOnce; |
333 | S32 mType; | ||
315 | LLVector3d mPositionGlobal; | 334 | LLVector3d mPositionGlobal; |
316 | LLVector3 mVelocity; | 335 | LLVector3 mVelocity; |
317 | 336 | ||
@@ -380,6 +399,9 @@ public: | |||
380 | virtual void setSource(LLAudioSource *sourcep); | 399 | virtual void setSource(LLAudioSource *sourcep); |
381 | LLAudioSource *getSource() const { return mCurrentSourcep; } | 400 | LLAudioSource *getSource() const { return mCurrentSourcep; } |
382 | 401 | ||
402 | void setSecondaryGain(F32 gain) { mSecondaryGain = gain; } | ||
403 | F32 getSecondaryGain() { return mSecondaryGain; } | ||
404 | |||
383 | friend class LLAudioEngine; | 405 | friend class LLAudioEngine; |
384 | friend class LLAudioSource; | 406 | friend class LLAudioSource; |
385 | protected: | 407 | protected: |
@@ -398,6 +420,7 @@ protected: | |||
398 | LLAudioBuffer *mCurrentBufferp; | 420 | LLAudioBuffer *mCurrentBufferp; |
399 | BOOL mLoopedThisFrame; | 421 | BOOL mLoopedThisFrame; |
400 | BOOL mWaiting; // Waiting for sync. | 422 | BOOL mWaiting; // Waiting for sync. |
423 | F32 mSecondaryGain; | ||
401 | }; | 424 | }; |
402 | 425 | ||
403 | 426 | ||
diff --git a/linden/indra/llaudio/audioengine_fmod.cpp b/linden/indra/llaudio/audioengine_fmod.cpp index 16d820c..4bf0c95 100644 --- a/linden/indra/llaudio/audioengine_fmod.cpp +++ b/linden/indra/llaudio/audioengine_fmod.cpp | |||
@@ -488,7 +488,7 @@ BOOL LLAudioChannelFMOD::updateBuffer() | |||
488 | if (mCurrentSourcep) | 488 | if (mCurrentSourcep) |
489 | { | 489 | { |
490 | // SJB: warnings can spam and hurt framerate, disabling | 490 | // SJB: warnings can spam and hurt framerate, disabling |
491 | if (!FSOUND_SetVolume(mChannelID, llround(mCurrentSourcep->getGain() * 255.0f))) | 491 | if (!FSOUND_SetVolume(mChannelID, llround(getSecondaryGain() * mCurrentSourcep->getGain() * 255.0f))) |
492 | { | 492 | { |
493 | // llwarns << "LLAudioChannelFMOD::updateBuffer error: " << FMOD_ErrorString(FSOUND_GetError()) << llendl; | 493 | // llwarns << "LLAudioChannelFMOD::updateBuffer error: " << FMOD_ErrorString(FSOUND_GetError()) << llendl; |
494 | } | 494 | } |