summaryrefslogtreecommitdiff
path: root/indra/newview/llaudiosourcevo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llaudiosourcevo.cpp')
-rw-r--r--indra/newview/llaudiosourcevo.cpp95
1 files changed, 52 insertions, 43 deletions
diff --git a/indra/newview/llaudiosourcevo.cpp b/indra/newview/llaudiosourcevo.cpp
index 50363ea2e7..b37aba6c15 100644
--- a/indra/newview/llaudiosourcevo.cpp
+++ b/indra/newview/llaudiosourcevo.cpp
@@ -3,31 +3,25 @@
* @author Douglas Soo, James Cook
* @brief Audio sources attached to viewer objects
*
- * $LicenseInfo:firstyear=2006&license=viewergpl$
- *
- * Copyright (c) 2006-2009, Linden Research, Inc.
- *
+ * $LicenseInfo:firstyear=2006&license=viewerlgpl$
* Second Life Viewer Source Code
- * The source code in this file ("Source Code") is provided by Linden Lab
- * to you under the terms of the GNU General Public License, version 2.0
- * ("GPL"), unless you have obtained a separate licensing agreement
- * ("Other License"), formally executed by you and Linden Lab. Terms of
- * the GPL can be found in doc/GPL-license.txt in this distribution, or
- * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ * Copyright (C) 2010, Linden Research, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation;
+ * version 2.1 of the License only.
*
- * There are special exceptions to the terms and conditions of the GPL as
- * it is applied to this Source Code. View the full text of the exception
- * in the file doc/FLOSS-exception.txt in this software distribution, or
- * online at
- * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*
- * By copying, modifying or distributing this software, you acknowledge
- * that you have read and understood your obligations described above,
- * and agree to abide by those obligations.
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
- * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
- * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
- * COMPLETENESS OR PERFORMANCE.
+ * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
@@ -41,11 +35,8 @@
LLAudioSourceVO::LLAudioSourceVO(const LLUUID &sound_id, const LLUUID& owner_id, const F32 gain, LLViewerObject *objectp)
: LLAudioSource(sound_id, owner_id, gain, LLAudioEngine::AUDIO_TYPE_SFX),
- mObjectp(objectp),
- mActualGain(gain)
+ mObjectp(objectp)
{
- setAmbient(FALSE);
- updateGain();
update();
}
@@ -60,18 +51,18 @@ LLAudioSourceVO::~LLAudioSourceVO()
void LLAudioSourceVO::setGain(const F32 gain)
{
- mActualGain = llclamp(gain, 0.f, 1.f);
- updateGain();
+ mGain = llclamp(gain, 0.f, 1.f);
}
-void LLAudioSourceVO::updateGain()
+void LLAudioSourceVO::updateMute()
{
- if (!mObjectp)
+ if (!mObjectp || mObjectp->isDead())
{
+ mSourceMuted = true;
return;
}
- BOOL mute = FALSE;
+ bool mute = false;
LLVector3d pos_global;
if (mObjectp->isAttachment())
@@ -90,21 +81,21 @@ void LLAudioSourceVO::updateGain()
{
pos_global = mObjectp->getPositionGlobal();
}
-
+
if (!LLViewerParcelMgr::getInstance()->canHearSound(pos_global))
{
- mute = TRUE;
+ mute = true;
}
if (!mute)
{
if (LLMuteList::getInstance()->isMuted(mObjectp->getID()))
{
- mute = TRUE;
+ mute = true;
}
else if (LLMuteList::getInstance()->isMuted(mOwnerID, LLMute::flagObjectSounds))
{
- mute = TRUE;
+ mute = true;
}
else if (mObjectp->isAttachment())
{
@@ -116,24 +107,38 @@ void LLAudioSourceVO::updateGain()
if (parent
&& LLMuteList::getInstance()->isMuted(parent->getID()))
{
- mute = TRUE;
+ mute = true;
}
}
}
- if (!mute)
+ if (mute != mSourceMuted)
{
- mGain = mActualGain;
- }
- else
- {
- mGain = 0.f;
+ mSourceMuted = mute;
+ if (mSourceMuted)
+ {
+ // Stop the sound.
+ this->play(LLUUID::null);
+ }
+ else
+ {
+ // Muted sounds keep there data at all times, because
+ // it's the place where the audio UUID is stored.
+ // However, it's possible that mCurrentDatap is
+ // NULL when this source did only preload sounds.
+ if (mCurrentDatap)
+ {
+ // Restart the sound.
+ this->play(mCurrentDatap->getID());
+ }
+ }
}
}
-
void LLAudioSourceVO::update()
{
+ updateMute();
+
if (!mObjectp)
{
return;
@@ -145,7 +150,11 @@ void LLAudioSourceVO::update()
return;
}
- updateGain();
+ if (mSourceMuted)
+ {
+ return;
+ }
+
if (mObjectp->isHUDAttachment())
{
mPositionGlobal = gAgentCamera.getCameraPositionGlobal();