summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--indra/llplugin/llpluginclassmedia.cpp5
-rw-r--r--indra/llplugin/llpluginclassmedia.h1
-rw-r--r--indra/newview/llviewermedia.cpp43
-rw-r--r--indra/newview/llviewermedia.h4
4 files changed, 46 insertions, 7 deletions
diff --git a/indra/llplugin/llpluginclassmedia.cpp b/indra/llplugin/llpluginclassmedia.cpp
index 6556aa33a4..26802bbd1c 100644
--- a/indra/llplugin/llpluginclassmedia.cpp
+++ b/indra/llplugin/llpluginclassmedia.cpp
@@ -1129,6 +1129,11 @@ void LLPluginClassMedia::setVolume(float volume)
}
}
+float LLPluginClassMedia::getVolume()
+{
+ return mRequestedVolume;
+}
+
void LLPluginClassMedia::initializeUrlHistory(const LLSD& url_history)
{
// Send URL history to plugin
diff --git a/indra/llplugin/llpluginclassmedia.h b/indra/llplugin/llpluginclassmedia.h
index 603817b7d0..4f9763474e 100644
--- a/indra/llplugin/llpluginclassmedia.h
+++ b/indra/llplugin/llpluginclassmedia.h
@@ -227,6 +227,7 @@ public:
void seek(float time);
void setLoop(bool loop);
void setVolume(float volume);
+ float getVolume();
F64 getCurrentTime(void) const { return mCurrentTime; };
F64 getDuration(void) const { return mDuration; };
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;
diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h
index 01640de33a..79bf3199d4 100644
--- a/indra/newview/llviewermedia.h
+++ b/indra/newview/llviewermedia.h
@@ -95,6 +95,7 @@ class LLViewerMedia
static void toggleMusicPlay(void*);
static void toggleMediaPlay(void*);
static void mediaStop(void*);
+ static F32 getVolume();
};
// Implementation functions not exported into header file
@@ -130,6 +131,8 @@ public:
void start();
void seek(F32 time);
void setVolume(F32 volume);
+ void updateVolume();
+ F32 getVolume();
void focus(bool focus);
// True if the impl has user focus.
bool hasFocus() const;
@@ -286,6 +289,7 @@ public:
bool mDoNavigateOnLoadRediscoverType;
bool mDoNavigateOnLoadServerRequest;
bool mMediaSourceFailedInit;
+ F32 mRequestedVolume;
private: