diff options
author | Monroe Linden <monroe@lindenlab.com> | 2009-10-26 17:13:38 -0700 |
---|---|---|
committer | Monroe Linden <monroe@lindenlab.com> | 2009-10-26 17:13:38 -0700 |
commit | 7f25433ccbdfb51e7e71722d4cc91ac0bef65871 (patch) | |
tree | bf7c45e7d751a3d1d9228f773402d6c67567120b | |
parent | ca903a11806dc1ab1394900944c82957124c362d (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).
-rw-r--r-- | indra/llplugin/llpluginclassmedia.cpp | 5 | ||||
-rw-r--r-- | indra/llplugin/llpluginclassmedia.h | 1 | ||||
-rw-r--r-- | indra/newview/llviewermedia.cpp | 43 | ||||
-rw-r--r-- | indra/newview/llviewermedia.h | 4 |
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: |