summaryrefslogtreecommitdiff
path: root/indra/newview/llviewermedia.cpp
diff options
context:
space:
mode:
authorMonroe Linden <monroe@lindenlab.com>2009-10-26 17:13:38 -0700
committerMonroe Linden <monroe@lindenlab.com>2009-10-26 17:13:38 -0700
commit7f25433ccbdfb51e7e71722d4cc91ac0bef65871 (patch)
treebf7c45e7d751a3d1d9228f773402d6c67567120b /indra/newview/llviewermedia.cpp
parentca903a11806dc1ab1394900944c82957124c362d (diff)
Volume controls in the media HUD should now work -- this fixes DEV-41746, DEV-41748, and DEV-40782.
Added LLPluginClassMedia::getVolume(). Added setVolume/getVolumeupdateVolume methods to LLViewerMediaImpl. LLViewerMedia::setVolume() now no longer overrides the volume settings on all media instances -- it now sets a "global volume" value which is multiplied by all instances' volumes to modulate them. Cleaned up volume/mute handling in LLPanelMediaHUD (made it go through the LLViewerMediaImpl interface instead of directly through LLPluginClassMedia, and removed the mMediaVolume member variable, since the media impl now stores that state).
Diffstat (limited to 'indra/newview/llviewermedia.cpp')
-rw-r--r--indra/newview/llviewermedia.cpp43
1 files changed, 36 insertions, 7 deletions
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 464ba4a5b1..b0f22166a0 100644
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -171,6 +171,7 @@ typedef std::vector<LLViewerMediaImpl*> impl_list;
static impl_list sViewerMediaImplList;
static LLTimer sMediaCreateTimer;
static const F32 LLVIEWERMEDIA_CREATE_DELAY = 1.0f;
+static F32 sGlobalVolume = 1.0f;
//////////////////////////////////////////////////////////////////////////////////////////
static void add_media_impl(LLViewerMediaImpl* media)
@@ -388,16 +389,27 @@ bool LLViewerMedia::textureHasMedia(const LLUUID& texture_id)
// static
void LLViewerMedia::setVolume(F32 volume)
{
- impl_list::iterator iter = sViewerMediaImplList.begin();
- impl_list::iterator end = sViewerMediaImplList.end();
-
- for(; iter != end; iter++)
+ if(volume != sGlobalVolume)
{
- LLViewerMediaImpl* pimpl = *iter;
- pimpl->setVolume(volume);
+ sGlobalVolume = volume;
+ impl_list::iterator iter = sViewerMediaImplList.begin();
+ impl_list::iterator end = sViewerMediaImplList.end();
+
+ for(; iter != end; iter++)
+ {
+ LLViewerMediaImpl* pimpl = *iter;
+ pimpl->updateVolume();
+ }
}
}
+//////////////////////////////////////////////////////////////////////////////////////////
+// static
+F32 LLViewerMedia::getVolume()
+{
+ return sGlobalVolume;
+}
+
// This is the predicate function used to sort sViewerMediaImplList by priority.
static inline bool compare_impl_interest(const LLViewerMediaImpl* i1, const LLViewerMediaImpl* i2)
{
@@ -592,6 +604,7 @@ LLViewerMediaImpl::LLViewerMediaImpl( const LLUUID& texture_id,
mDoNavigateOnLoadRediscoverType(false),
mDoNavigateOnLoadServerRequest(false),
mMediaSourceFailedInit(false),
+ mRequestedVolume(1.0f),
mIsUpdated(false)
{
@@ -796,6 +809,9 @@ bool LLViewerMediaImpl::initializePlugin(const std::string& media_type)
media_source->focus(mHasFocus);
mMediaSource = media_source;
+
+ updateVolume();
+
return true;
}
@@ -886,13 +902,26 @@ void LLViewerMediaImpl::seek(F32 time)
//////////////////////////////////////////////////////////////////////////////////////////
void LLViewerMediaImpl::setVolume(F32 volume)
{
+ mRequestedVolume = volume;
+ updateVolume();
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+void LLViewerMediaImpl::updateVolume()
+{
if(mMediaSource)
{
- mMediaSource->setVolume(volume);
+ mMediaSource->setVolume(mRequestedVolume * LLViewerMedia::getVolume());
}
}
//////////////////////////////////////////////////////////////////////////////////////////
+F32 LLViewerMediaImpl::getVolume()
+{
+ return mRequestedVolume;
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
void LLViewerMediaImpl::focus(bool focus)
{
mHasFocus = focus;