Annotation of /trunk/indra/newview/llaudiosourcevo.cpp
Parent Directory
|
Revision Log
Revision 135 - (view) (download)
| 1 : | mjm | 135 | /** |
| 2 : | * @file llaudiosourcevo.cpp | ||
| 3 : | * @author Douglas Soo, James Cook | ||
| 4 : | * @brief Audio sources attached to viewer objects | ||
| 5 : | * | ||
| 6 : | * $LicenseInfo:firstyear=2006&license=viewergpl$ | ||
| 7 : | * | ||
| 8 : | * Copyright (c) 2006-2009, Linden Research, Inc. | ||
| 9 : | * | ||
| 10 : | * Second Life Viewer Source Code | ||
| 11 : | * The source code in this file ("Source Code") is provided by Linden Lab | ||
| 12 : | * to you under the terms of the GNU General Public License, version 2.0 | ||
| 13 : | * ("GPL"), unless you have obtained a separate licensing agreement | ||
| 14 : | * ("Other License"), formally executed by you and Linden Lab. Terms of | ||
| 15 : | * the GPL can be found in doc/GPL-license.txt in this distribution, or | ||
| 16 : | * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2 | ||
| 17 : | * | ||
| 18 : | * There are special exceptions to the terms and conditions of the GPL as | ||
| 19 : | * it is applied to this Source Code. View the full text of the exception | ||
| 20 : | * in the file doc/FLOSS-exception.txt in this software distribution, or | ||
| 21 : | * online at | ||
| 22 : | * http://secondlifegrid.net/programs/open_source/licensing/flossexception | ||
| 23 : | * | ||
| 24 : | * By copying, modifying or distributing this software, you acknowledge | ||
| 25 : | * that you have read and understood your obligations described above, | ||
| 26 : | * and agree to abide by those obligations. | ||
| 27 : | * | ||
| 28 : | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | ||
| 29 : | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | ||
| 30 : | * COMPLETENESS OR PERFORMANCE. | ||
| 31 : | * $/LicenseInfo$ | ||
| 32 : | */ | ||
| 33 : | |||
| 34 : | #include "llviewerprecompiledheaders.h" | ||
| 35 : | |||
| 36 : | #include "llaudiosourcevo.h" | ||
| 37 : | |||
| 38 : | #include "llagent.h" | ||
| 39 : | #include "llmutelist.h" | ||
| 40 : | #include "llviewerparcelmgr.h" | ||
| 41 : | |||
| 42 : | LLAudioSourceVO::LLAudioSourceVO(const LLUUID &sound_id, const LLUUID& owner_id, const F32 gain, LLViewerObject *objectp) | ||
| 43 : | : LLAudioSource(sound_id, owner_id, gain, LLAudioEngine::AUDIO_TYPE_SFX), | ||
| 44 : | mObjectp(objectp), | ||
| 45 : | mActualGain(gain) | ||
| 46 : | { | ||
| 47 : | setAmbient(FALSE); | ||
| 48 : | updateGain(); | ||
| 49 : | update(); | ||
| 50 : | } | ||
| 51 : | |||
| 52 : | LLAudioSourceVO::~LLAudioSourceVO() | ||
| 53 : | { | ||
| 54 : | if (mObjectp) | ||
| 55 : | { | ||
| 56 : | mObjectp->clearAttachedSound(); | ||
| 57 : | } | ||
| 58 : | mObjectp = NULL; | ||
| 59 : | } | ||
| 60 : | |||
| 61 : | void LLAudioSourceVO::setGain(const F32 gain) | ||
| 62 : | { | ||
| 63 : | mActualGain = llclamp(gain, 0.f, 1.f); | ||
| 64 : | updateGain(); | ||
| 65 : | } | ||
| 66 : | |||
| 67 : | void LLAudioSourceVO::updateGain() | ||
| 68 : | { | ||
| 69 : | if (!mObjectp) | ||
| 70 : | { | ||
| 71 : | return; | ||
| 72 : | } | ||
| 73 : | |||
| 74 : | BOOL mute = FALSE; | ||
| 75 : | LLVector3d pos_global; | ||
| 76 : | |||
| 77 : | if (mObjectp->isAttachment()) | ||
| 78 : | { | ||
| 79 : | LLViewerObject* parent = mObjectp; | ||
| 80 : | while (parent && !parent->isAvatar()) | ||
| 81 : | { | ||
| 82 : | parent = (LLViewerObject*)parent->getParent(); | ||
| 83 : | } | ||
| 84 : | if (parent) | ||
| 85 : | { | ||
| 86 : | pos_global = parent->getPositionGlobal(); | ||
| 87 : | } | ||
| 88 : | } | ||
| 89 : | else | ||
| 90 : | { | ||
| 91 : | pos_global = mObjectp->getPositionGlobal(); | ||
| 92 : | } | ||
| 93 : | |||
| 94 : | if (!LLViewerParcelMgr::getInstance()->canHearSound(pos_global)) | ||
| 95 : | { | ||
| 96 : | mute = TRUE; | ||
| 97 : | } | ||
| 98 : | |||
| 99 : | if (!mute) | ||
| 100 : | { | ||
| 101 : | if (LLMuteList::getInstance()->isMuted(mObjectp->getID())) | ||
| 102 : | { | ||
| 103 : | mute = TRUE; | ||
| 104 : | } | ||
| 105 : | else if (LLMuteList::getInstance()->isMuted(mOwnerID, LLMute::flagObjectSounds)) | ||
| 106 : | { | ||
| 107 : | mute = TRUE; | ||
| 108 : | } | ||
| 109 : | else if (mObjectp->isAttachment()) | ||
| 110 : | { | ||
| 111 : | LLViewerObject* parent = mObjectp; | ||
| 112 : | while (parent && !parent->isAvatar()) | ||
| 113 : | { | ||
| 114 : | parent = (LLViewerObject*)parent->getParent(); | ||
| 115 : | } | ||
| 116 : | if (parent | ||
| 117 : | && LLMuteList::getInstance()->isMuted(parent->getID())) | ||
| 118 : | { | ||
| 119 : | mute = TRUE; | ||
| 120 : | } | ||
| 121 : | } | ||
| 122 : | } | ||
| 123 : | |||
| 124 : | if (!mute) | ||
| 125 : | { | ||
| 126 : | mGain = mActualGain; | ||
| 127 : | } | ||
| 128 : | else | ||
| 129 : | { | ||
| 130 : | mGain = 0.f; | ||
| 131 : | } | ||
| 132 : | } | ||
| 133 : | |||
| 134 : | |||
| 135 : | void LLAudioSourceVO::update() | ||
| 136 : | { | ||
| 137 : | if (!mObjectp) | ||
| 138 : | { | ||
| 139 : | return; | ||
| 140 : | } | ||
| 141 : | |||
| 142 : | if (mObjectp->isDead()) | ||
| 143 : | { | ||
| 144 : | mObjectp = NULL; | ||
| 145 : | return; | ||
| 146 : | } | ||
| 147 : | |||
| 148 : | updateGain(); | ||
| 149 : | if (mObjectp->isHUDAttachment()) | ||
| 150 : | { | ||
| 151 : | mPositionGlobal = gAgent.getCameraPositionGlobal(); | ||
| 152 : | } | ||
| 153 : | else | ||
| 154 : | { | ||
| 155 : | mPositionGlobal = mObjectp->getPositionGlobal(); | ||
| 156 : | } | ||
| 157 : | if (mObjectp->getSubParent()) | ||
| 158 : | { | ||
| 159 : | mVelocity = mObjectp->getSubParent()->getVelocity(); | ||
| 160 : | } | ||
| 161 : | else | ||
| 162 : | { | ||
| 163 : | mVelocity = mObjectp->getVelocity(); | ||
| 164 : | } | ||
| 165 : | |||
| 166 : | LLAudioSource::update(); | ||
| 167 : | } |
| ViewVC Help | |
| Powered by ViewVC 1.0.0 |

