From 1f8fb3f3bae92b9e632b8793ce4d8f59f9dfc1aa Mon Sep 17 00:00:00 2001
From: Mike Antipov <mantipov@productengine.com>
Date: Tue, 23 Feb 2010 15:33:10 +0200
Subject: [PATCH] Work on major bug EXT-5562 (Misleading Active Voice
 Indicators in Group Chat Window, when Speakers are in Spatial Chat Only) -
 updated code to store target session id for which registered indicator should
 be shown and process it while switching indicators on.

--HG--
branch : product-engine
---
 indra/newview/llspeakingindicatormanager.cpp | 22 +++++++++++++++++++-
 indra/newview/llspeakingindicatormanager.h   | 11 ++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llspeakingindicatormanager.cpp b/indra/newview/llspeakingindicatormanager.cpp
index 74b45217d30..012e092a7fb 100644
--- a/indra/newview/llspeakingindicatormanager.cpp
+++ b/indra/newview/llspeakingindicatormanager.cpp
@@ -152,6 +152,8 @@ void SpeakingIndicatorManager::registerSpeakingIndicator(const LLUUID& speaker_i
 
 	ensureInstanceDoesNotExist(speaking_indicator);
 
+	speaking_indicator->setTargetSessionID(session_id);
+
 	speaking_indicator_value_t value_type(speaker_id, speaking_indicator);
 	mSpeakingIndicators.insert(value_type);
 
@@ -222,6 +224,13 @@ void SpeakingIndicatorManager::onChange()
 
 void SpeakingIndicatorManager::switchSpeakerIndicators(const speaker_ids_t& speakers_uuids, BOOL switch_on)
 {
+	LLVoiceChannel* voice_channel = LLVoiceChannel::getCurrentVoiceChannel();
+	LLUUID session_id;
+	if (voice_channel)
+	{
+		session_id = voice_channel->getSessionID();
+	}
+
 	speaker_ids_t::const_iterator it_uuid = speakers_uuids.begin(); 
 	for (; it_uuid != speakers_uuids.end(); ++it_uuid)
 	{
@@ -233,13 +242,24 @@ void SpeakingIndicatorManager::switchSpeakerIndicators(const speaker_ids_t& spea
 		{
 			was_found = true;
 			LLSpeakingIndicator* indicator = (*it_indicator).second;
-			indicator->switchIndicator(switch_on);
+
+			BOOL switch_current_on = switch_on;
+
+			// we should show indicator for specified voice session only if this is current channel. EXT-5562.
+			if (switch_current_on && indicator->getTargetSessionID().notNull())
+			{
+				switch_current_on = indicator->getTargetSessionID() == session_id;
+			}
+
+			indicator->switchIndicator(switch_current_on);
 		}
 
 		if (was_found)
 		{
 			LL_DEBUGS("SpeakingIndicator") << mSpeakingIndicators.count(*it_uuid) << " indicators where found" << LL_ENDL;
 
+			// *TODO: it is possible non of the registered indicators are in the target session
+			// we can avoid of storing such UUID in the mSwitchedIndicatorsOn map in this case.
 			if (switch_on)
 			{
 				// store switched on indicator to be able switch it off
diff --git a/indra/newview/llspeakingindicatormanager.h b/indra/newview/llspeakingindicatormanager.h
index cd72b85bfde..b75c65c0648 100644
--- a/indra/newview/llspeakingindicatormanager.h
+++ b/indra/newview/llspeakingindicatormanager.h
@@ -38,7 +38,18 @@
 class LLSpeakingIndicator
 {
 public:
+	virtual ~LLSpeakingIndicator(){}
 	virtual void switchIndicator(bool switch_on) = 0;
+	void setTargetSessionID(const LLUUID& session_id) { mTargetSessionID = session_id; }
+	const LLUUID& getTargetSessionID() { return mTargetSessionID; }
+
+private:
+	/**
+	 * session UUID for which indicator should be shown only.
+	 *		If it is set, registered indicator will be shown only in voice channel
+	 *		which has the same session id (EXT-5562).
+	 */
+	LLUUID mTargetSessionID;
 };
 
 // See EXT-3976.
-- 
GitLab