diff options
author | Monroe Linden <monroe@lindenlab.com> | 2009-10-30 12:33:25 -0700 |
---|---|---|
committer | Monroe Linden <monroe@lindenlab.com> | 2009-10-30 12:33:25 -0700 |
commit | 043d2d1f9dbdacff46e24f73b184dac8532d2db6 (patch) | |
tree | 87229158515368e5ac950ef16ff7e72192e99c3d /indra | |
parent | a98591802a46a0ae5b09bbc3eb530d76b49cb2b4 (diff) |
Hooks for the "nearby media" UI.
Added LLViewerMediaImpl::set/getDisabled(), which will prevent a media instance from loading.
Added LLViewerMedia::set/getInWorldMediaDisabled(), which will disable all inworld media fom loading.
Added LLViewerMedia::getPriorityList() and made the priority comparitor public.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/newview/llviewermedia.cpp | 56 | ||||
-rw-r--r-- | indra/newview/llviewermedia.h | 20 |
2 files changed, 67 insertions, 9 deletions
diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp index e2d9f5a2c9..e8835b34f0 100644 --- a/indra/newview/llviewermedia.cpp +++ b/indra/newview/llviewermedia.cpp @@ -168,8 +168,7 @@ public: viewer_media_t mMediaImpl; bool mInitialized; }; -typedef std::vector<LLViewerMediaImpl*> impl_list; -static impl_list sViewerMediaImplList; +static LLViewerMedia::impl_list sViewerMediaImplList; static LLTimer sMediaCreateTimer; static const F32 LLVIEWERMEDIA_CREATE_DELAY = 1.0f; static F32 sGlobalVolume = 1.0f; @@ -183,8 +182,8 @@ static void add_media_impl(LLViewerMediaImpl* media) ////////////////////////////////////////////////////////////////////////////////////////// static void remove_media_impl(LLViewerMediaImpl* media) { - impl_list::iterator iter = sViewerMediaImplList.begin(); - impl_list::iterator end = sViewerMediaImplList.end(); + LLViewerMedia::impl_list::iterator iter = sViewerMediaImplList.begin(); + LLViewerMedia::impl_list::iterator end = sViewerMediaImplList.end(); for(; iter != end; iter++) { @@ -203,6 +202,7 @@ class LLViewerMediaMuteListObserver : public LLMuteListObserver static LLViewerMediaMuteListObserver sViewerMediaMuteListObserver; static bool sViewerMediaMuteListObserverInitialized = false; +static bool sInWorldMediaDisabled = false; ////////////////////////////////////////////////////////////////////////////////////////// @@ -428,15 +428,31 @@ void LLViewerMedia::muteListChanged() } } +////////////////////////////////////////////////////////////////////////////////////////// +// static +void LLViewerMedia::setInWorldMediaDisabled(bool disabled) +{ + sInWorldMediaDisabled = disabled; +} + +////////////////////////////////////////////////////////////////////////////////////////// +// static +bool LLViewerMedia::getInWorldMediaDisabled() +{ + return sInWorldMediaDisabled; +} + +static const impl_list &getPriorityList(); + // This is the predicate function used to sort sViewerMediaImplList by priority. -static inline bool compare_impl_interest(const LLViewerMediaImpl* i1, const LLViewerMediaImpl* i2) +bool LLViewerMedia::priorityComparitor(const LLViewerMediaImpl* i1, const LLViewerMediaImpl* i2) { - if(i1->mIsMuted || i1->mMediaSourceFailed) + if(i1->isForcedUnloaded()) { // Muted or failed items always go to the end of the list, period. return false; } - else if(i2->mIsMuted || i2->mMediaSourceFailed) + else if(i2->isForcedUnloaded()) { // Muted or failed items always go to the end of the list, period. return true; @@ -483,7 +499,7 @@ void LLViewerMedia::updateMedia() } // Sort the static instance list using our interest criteria - std::stable_sort(sViewerMediaImplList.begin(), sViewerMediaImplList.end(), compare_impl_interest); + std::stable_sort(sViewerMediaImplList.begin(), sViewerMediaImplList.end(), priorityComparitor); // Go through the list again and adjust according to priority. iter = sViewerMediaImplList.begin(); @@ -515,7 +531,7 @@ void LLViewerMedia::updateMedia() LLPluginClassMedia::EPriority new_priority = LLPluginClassMedia::PRIORITY_NORMAL; - if(pimpl->mIsMuted || pimpl->mMediaSourceFailed || (impl_count_total > (int)max_instances)) + if(pimpl->isForcedUnloaded() || (impl_count_total > (int)max_instances)) { // Never load muted or failed impls. // Hard limit on the number of instances that will be loaded at one time @@ -641,6 +657,7 @@ LLViewerMediaImpl::LLViewerMediaImpl( const LLUUID& texture_id, mNeedsMuteCheck(false), mPreviousMediaState(MEDIA_NONE), mPreviousMediaTime(0.0f), + mIsDisabled(false), mIsUpdated(false) { @@ -1650,6 +1667,27 @@ void LLViewerMediaImpl::resetPreviousMediaState() } ////////////////////////////////////////////////////////////////////////////////////////// +// +bool LLViewerMediaImpl::isForcedUnloaded() +{ + if(mIsMuted || mMediaSourceFailed || mIsDisabled) + { + return true; + } + + if(sInWorldMediaDisabled) + { + // When inworld media is disabled, all instances that aren't marked as "used in UI" will not be loaded. + if(!mUsedInUI) + { + return true; + } + } + + return false; +} + +////////////////////////////////////////////////////////////////////////////////////////// void LLViewerMediaImpl::handleMediaEvent(LLPluginClassMedia* plugin, LLPluginClassMediaOwner::EMediaEvent event) { switch(event) diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h index 5444abf854..043259a235 100644 --- a/indra/newview/llviewermedia.h +++ b/indra/newview/llviewermedia.h @@ -66,10 +66,15 @@ private: observerListType mObservers; }; +class LLViewerMediaImpl; + class LLViewerMedia { LOG_CLASS(LLViewerMedia); public: + + typedef std::vector<LLViewerMediaImpl*> impl_list; + // Special case early init for just web browser component // so we can show login screen. See .cpp file for details. JC @@ -97,6 +102,14 @@ class LLViewerMedia static void mediaStop(void*); static F32 getVolume(); static void muteListChanged(); + static void setInWorldMediaDisabled(bool disabled); + static bool getInWorldMediaDisabled(); + + // Returns the priority-sorted list of all media impls. + static const impl_list &getPriorityList(); + + // This is the comparitor used to sort the list. + static bool priorityComparitor(const LLViewerMediaImpl* i1, const LLViewerMediaImpl* i2) }; // Implementation functions not exported into header file @@ -179,6 +192,12 @@ public: bool hasMedia(); bool isMediaFailed() { return mMediaSourceFailed; }; void resetPreviousMediaState(); + + void setDisabled(bool disabled) { mIsDisabled = disabled; }; + bool isMediaDisabled() { return mIsDisabled; }; + + // returns true if this instance should not be loaded (disabled, muted object, crashed, etc.) + bool isForcedUnloaded(); ECursorType getLastSetCursor() { return mLastSetCursor; }; @@ -301,6 +320,7 @@ public: bool mNeedsMuteCheck; int mPreviousMediaState; F64 mPreviousMediaTime; + bool mIsDisabled; private: BOOL mIsUpdated ; |