summaryrefslogtreecommitdiff
path: root/indra/newview/llspeakingindicatormanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llspeakingindicatormanager.cpp')
-rw-r--r--indra/newview/llspeakingindicatormanager.cpp86
1 files changed, 79 insertions, 7 deletions
diff --git a/indra/newview/llspeakingindicatormanager.cpp b/indra/newview/llspeakingindicatormanager.cpp
index 5e1d408e8d..cc06179481 100644
--- a/indra/newview/llspeakingindicatormanager.cpp
+++ b/indra/newview/llspeakingindicatormanager.cpp
@@ -65,8 +65,12 @@ public:
*
* @param speaker_id LLUUID of an avatar whose speaking indicator is registered.
* @param speaking_indicator instance of the speaking indicator to be registered.
+ * @param session_id session UUID for which indicator should be shown only.
+ * If this parameter is set registered indicator will be shown only in voice channel
+ * which has the same session id (EXT-5562).
*/
- void registerSpeakingIndicator(const LLUUID& speaker_id, LLSpeakingIndicator* const speaking_indicator);
+ void registerSpeakingIndicator(const LLUUID& speaker_id, LLSpeakingIndicator* const speaking_indicator,
+ const LLUUID& session_id = LLUUID::null);
/**
* Removes passed speaking indicator from observing.
@@ -114,6 +118,13 @@ private:
void switchSpeakerIndicators(const speaker_ids_t& speakers_uuids, BOOL switch_on);
/**
+ * Ensures that passed instance of Speaking Indicator does not exist among registered ones.
+ * If yes, it will be removed.
+ */
+ void ensureInstanceDoesNotExist(LLSpeakingIndicator* const speaking_indicator);
+
+
+ /**
* Multimap with all registered speaking indicators
*/
speaking_indicators_mmap_t mSpeakingIndicators;
@@ -131,11 +142,18 @@ private:
//////////////////////////////////////////////////////////////////////////
// PUBLIC SECTION
//////////////////////////////////////////////////////////////////////////
-void SpeakingIndicatorManager::registerSpeakingIndicator(const LLUUID& speaker_id, LLSpeakingIndicator* const speaking_indicator)
+void SpeakingIndicatorManager::registerSpeakingIndicator(const LLUUID& speaker_id, LLSpeakingIndicator* const speaking_indicator,
+ const LLUUID& session_id)
{
// do not exclude agent's indicators. They should be processed in the same way as others. See EXT-3889.
- LL_DEBUGS("SpeakingIndicator") << "Registering indicator: " << speaker_id << LL_ENDL;
+ LL_DEBUGS("SpeakingIndicator") << "Registering indicator: " << speaker_id << "|"<< speaking_indicator << ", session: " << session_id << LL_ENDL;
+
+
+ ensureInstanceDoesNotExist(speaking_indicator);
+
+ speaking_indicator->setTargetSessionID(session_id);
+
speaking_indicator_value_t value_type(speaker_id, speaking_indicator);
mSpeakingIndicators.insert(value_type);
@@ -148,12 +166,14 @@ void SpeakingIndicatorManager::registerSpeakingIndicator(const LLUUID& speaker_i
void SpeakingIndicatorManager::unregisterSpeakingIndicator(const LLUUID& speaker_id, const LLSpeakingIndicator* const speaking_indicator)
{
+ LL_DEBUGS("SpeakingIndicator") << "Unregistering indicator: " << speaker_id << "|"<< speaking_indicator << LL_ENDL;
speaking_indicators_mmap_t::iterator it;
it = mSpeakingIndicators.find(speaker_id);
for (;it != mSpeakingIndicators.end(); ++it)
{
if (it->second == speaking_indicator)
{
+ LL_DEBUGS("SpeakingIndicator") << "Unregistered." << LL_ENDL;
mSpeakingIndicators.erase(it);
break;
}
@@ -204,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)
{
@@ -211,18 +238,36 @@ void SpeakingIndicatorManager::switchSpeakerIndicators(const speaker_ids_t& spea
indicator_range_t it_range = mSpeakingIndicators.equal_range(*it_uuid);
indicator_const_iterator it_indicator = it_range.first;
bool was_found = false;
+ bool was_switched_on = false;
for (; it_indicator != it_range.second; ++it_indicator)
{
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;
+ LL_DEBUGS("SpeakingIndicator") << "Session: " << session_id << ", target: " << indicator->getTargetSessionID() << ", the same? = " << switch_current_on << LL_ENDL;
+ }
+ was_switched_on = was_switched_on || switch_current_on;
+
+ indicator->switchIndicator(switch_current_on);
+
}
if (was_found)
{
LL_DEBUGS("SpeakingIndicator") << mSpeakingIndicators.count(*it_uuid) << " indicators where found" << LL_ENDL;
- if (switch_on)
+ if (switch_on && !was_switched_on)
+ {
+ LL_DEBUGS("SpeakingIndicator") << "but non of them where switched on" << LL_ENDL;
+ }
+
+ if (was_switched_on)
{
// store switched on indicator to be able switch it off
mSwitchedIndicatorsOn.insert(*it_uuid);
@@ -231,13 +276,40 @@ void SpeakingIndicatorManager::switchSpeakerIndicators(const speaker_ids_t& spea
}
}
+void SpeakingIndicatorManager::ensureInstanceDoesNotExist(LLSpeakingIndicator* const speaking_indicator)
+{
+ LL_DEBUGS("SpeakingIndicator") << "Searching for an registered indicator instance: " << speaking_indicator << LL_ENDL;
+ speaking_indicators_mmap_t::iterator it = mSpeakingIndicators.begin();
+ for (;it != mSpeakingIndicators.end(); ++it)
+ {
+ if (it->second == speaking_indicator)
+ {
+ LL_DEBUGS("SpeakingIndicator") << "Found" << LL_ENDL;
+ break;
+ }
+ }
+
+ // It is possible with LLOutputMonitorCtrl the same instance of indicator is registered several
+ // times with different UUIDs. This leads to crash after instance is destroyed because the
+ // only one (specified by UUID in unregisterSpeakingIndicator()) is removed from the map.
+ // So, using stored deleted pointer leads to crash. See EXT-4782.
+ if (it != mSpeakingIndicators.end())
+ {
+ llwarns << "The same instance of indicator has already been registered, removing it: " << it->first << "|"<< speaking_indicator << llendl;
+ llassert(it == mSpeakingIndicators.end());
+ mSpeakingIndicators.erase(it);
+ }
+}
+
+
/************************************************************************/
/* LLSpeakingIndicatorManager namespace implementation */
/************************************************************************/
-void LLSpeakingIndicatorManager::registerSpeakingIndicator(const LLUUID& speaker_id, LLSpeakingIndicator* const speaking_indicator)
+void LLSpeakingIndicatorManager::registerSpeakingIndicator(const LLUUID& speaker_id, LLSpeakingIndicator* const speaking_indicator,
+ const LLUUID& session_id)
{
- SpeakingIndicatorManager::instance().registerSpeakingIndicator(speaker_id, speaking_indicator);
+ SpeakingIndicatorManager::instance().registerSpeakingIndicator(speaker_id, speaking_indicator, session_id);
}
void LLSpeakingIndicatorManager::unregisterSpeakingIndicator(const LLUUID& speaker_id, const LLSpeakingIndicator* const speaking_indicator)