From 10592f78562f0ae582a0c4acfbc5caca83cdc618 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Wed, 6 Mar 2019 23:11:29 +0100 Subject: [PATCH] Improve NearbyVoiceMonitor to not trying to toggle visibility on each draw call --- indra/newview/lloutputmonitorctrl.cpp | 29 ++++++++++++++------------- indra/newview/lloutputmonitorctrl.h | 7 +++++-- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/indra/newview/lloutputmonitorctrl.cpp b/indra/newview/lloutputmonitorctrl.cpp index c8235e08a5..1318e227e7 100644 --- a/indra/newview/lloutputmonitorctrl.cpp +++ b/indra/newview/lloutputmonitorctrl.cpp @@ -77,7 +77,8 @@ LLOutputMonitorCtrl::LLOutputMonitorCtrl(const LLOutputMonitorCtrl::Params& p) mIsModeratorMuted(false), mIsAgentControl(false), mIndicatorToggled(false), - mShowParticipantsSpeaking(false) + mShowParticipantsSpeaking(false), + mAlwaysVisible(false) // Option to not hide it if speaker ID is set to null { //static LLUIColor output_monitor_muted_color = LLUIColorTable::instance().getColor("OutputMonitorMutedColor", LLColor4::orange); //static LLUIColor output_monitor_overdriven_color = LLUIColorTable::instance().getColor("OutputMonitorOverdrivenColor", LLColor4::red); @@ -297,7 +298,9 @@ void LLOutputMonitorCtrl::setSpeakerId(const LLUUID& speaker_id, const LLUUID& s if (speaker_id.isNull() && mSpeakerId.notNull()) { LLSpeakingIndicatorManager::unregisterSpeakingIndicator(mSpeakerId, this); - switchIndicator(false); + // Option to not hide it if speaker ID is set to null + if (!mAlwaysVisible) + switchIndicator(false); mSpeakerId = speaker_id; } @@ -384,7 +387,7 @@ void LLOutputMonitorCtrl::notifyParentVisibilityChanged() static LLDefaultChildRegistry::Register r2("nearby_voice_monitor"); NearbyVoiceMonitor::Params::Params() -: auto_hide("auto_hide",false) +: auto_hide("auto_hide", false) { } @@ -392,39 +395,37 @@ NearbyVoiceMonitor::NearbyVoiceMonitor(const NearbyVoiceMonitor::Params& p) : LLOutputMonitorCtrl(p), mAutoHide(p.auto_hide) { - mSpeakerMgr=LLLocalSpeakerMgr::getInstance(); + mAlwaysVisible = true; + mSpeakerMgr = LLLocalSpeakerMgr::getInstance(); } void NearbyVoiceMonitor::draw() { LLSpeakerMgr::speaker_list_t speaker_list; LLUUID id; - BOOL draw=FALSE; + bool draw = false; - id.setNull(); mSpeakerMgr->update(TRUE); mSpeakerMgr->getSpeakerList(&speaker_list, FALSE); - for (LLSpeakerMgr::speaker_list_t::iterator i = speaker_list.begin(); i != speaker_list.end(); ++i) + for (LLSpeakerMgr::speaker_list_t::const_iterator it = speaker_list.begin(); it != speaker_list.end(); ++it) { - LLPointer s = *i; - if (s->mSpeechVolume > 0 || s->mStatus == LLSpeaker::STATUS_SPEAKING) + LLPointer speaker = *it; + if (speaker->mSpeechVolume > 0.f || speaker->mStatus == LLSpeaker::STATUS_SPEAKING) { - draw=TRUE; - id = s->mID; + draw = true; + id = speaker->mID; break; } } setSpeakerId(id); - switchIndicator(true); // Ansa: Make sure the output monitor is visible at all times - if(!mAutoHide || draw) + if (!mAutoHide || draw) { LLOutputMonitorCtrl::draw(); } } - // Add new control to have a nearby voice output monitor ////////////////////////////////////////////////////////////////////////// diff --git a/indra/newview/lloutputmonitorctrl.h b/indra/newview/lloutputmonitorctrl.h index e6c847295a..953bda959c 100644 --- a/indra/newview/lloutputmonitorctrl.h +++ b/indra/newview/lloutputmonitorctrl.h @@ -63,6 +63,9 @@ protected: LLOutputMonitorCtrl(const Params&); friend class LLUICtrlFactory; + // Option to not hide it if speaker ID is set to null + bool mAlwaysVisible; + public: virtual ~LLOutputMonitorCtrl(); @@ -169,12 +172,12 @@ public: Params(); }; - NearbyVoiceMonitor(const Params& p); + NearbyVoiceMonitor(const Params& p); void draw(); protected: - BOOL mAutoHide; + bool mAutoHide; LLLocalSpeakerMgr* mSpeakerMgr; };