summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llviewermedia.cpp43
-rw-r--r--indra/newview/llviewermedia.h4
2 files changed, 40 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;
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: