diff options
-rw-r--r-- | indra/newview/llspeakingindicatormanager.cpp | 49 | ||||
-rw-r--r-- | indra/newview/llvoiceclient.cpp | 11 | ||||
-rw-r--r-- | indra/newview/llvoiceclient.h | 1 |
3 files changed, 19 insertions, 42 deletions
diff --git a/indra/newview/llspeakingindicatormanager.cpp b/indra/newview/llspeakingindicatormanager.cpp index 1c8fc6ac9d..8c0f48595b 100644 --- a/indra/newview/llspeakingindicatormanager.cpp +++ b/indra/newview/llspeakingindicatormanager.cpp @@ -78,7 +78,7 @@ public: void unregisterSpeakingIndicator(const LLUUID& speaker_id, const LLSpeakingIndicator* const speaking_indicator); private: - typedef std::vector<LLUUID> speaker_ids_t; + typedef std::set<LLUUID> speaker_ids_t; typedef std::multimap<LLUUID, LLSpeakingIndicator*> speaking_indicators_mmap_t; typedef speaking_indicators_mmap_t::value_type speaking_indicator_value_t; typedef speaking_indicators_mmap_t::const_iterator indicator_const_iterator; @@ -140,28 +140,10 @@ void SpeakingIndicatorManager::registerSpeakingIndicator(const LLUUID& speaker_i speaking_indicator_value_t value_type(speaker_id, speaking_indicator); mSpeakingIndicators.insert(value_type); - BOOL is_in_same_voice = FALSE; - - // search passed speaker id among a list of voice participants - LLVoiceClient::participantMap *voice_map = LLVoiceClient::getInstance()->getParticipantList(); - if (voice_map) - { - for (LLVoiceClient::participantMap::const_iterator iter = voice_map->begin(); - iter != voice_map->end(); ++iter) - { - const LLUUID id = (*iter).second->mAvatarID; - - if (speaker_id == id) - { - is_in_same_voice = TRUE; - break; - } - - } - } - speaker_ids_t speakers_uuids; - speakers_uuids.push_back(speaker_id); + BOOL is_in_same_voice = LLVoiceClient::getInstance()->findParticipantByID(speaker_id) != NULL; + + speakers_uuids.insert(speaker_id); switchSpeakerIndicators(speakers_uuids, is_in_same_voice); } @@ -209,23 +191,9 @@ void SpeakingIndicatorManager::onChange() LL_DEBUGS("SpeakingIndicator") << "Voice participant list was changed, updating indicators" << LL_ENDL; speaker_ids_t speakers_uuids; - // Get a list of participants from VoiceClient - LLVoiceClient::participantMap *voice_map = gVoiceClient->getParticipantList(); - if (voice_map) - { - for (LLVoiceClient::participantMap::const_iterator iter = voice_map->begin(); - iter != voice_map->end(); ++iter) - { - LLUUID id = (*iter).second->mAvatarID; - - if (id == gAgentID) continue; - - speakers_uuids.push_back(id); - } - } + LLVoiceClient::getInstance()->getParticipantsUUIDSet(speakers_uuids); LL_DEBUGS("SpeakingIndicator") << "Switching all OFF, count: " << mSwitchedIndicatorsOn.size() << LL_ENDL; - // switch all indicators off switchSpeakerIndicators(mSwitchedIndicatorsOn, FALSE); mSwitchedIndicatorsOn.clear(); @@ -257,11 +225,8 @@ void SpeakingIndicatorManager::switchSpeakerIndicators(const speaker_ids_t& spea if (switch_on) { - // TODO: probably std::set will be better - // if (mSwitchedIndicatorsOn.find(*it_uuid) == mSwitchedIndicatorsOn.end()) - { - mSwitchedIndicatorsOn.push_back(*it_uuid); - } + // store switched on indicator to be able switch it off + mSwitchedIndicatorsOn.insert(*it_uuid); } } else diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp index 423c46e14c..42b8a1c2b6 100644 --- a/indra/newview/llvoiceclient.cpp +++ b/indra/newview/llvoiceclient.cpp @@ -5004,6 +5004,17 @@ LLVoiceClient::participantMap *LLVoiceClient::getParticipantList(void) return result; } +void LLVoiceClient::getParticipantsUUIDSet(std::set<LLUUID>& participant_uuids) +{ + if (NULL == mAudioSession) return; + + participantUUIDMap::const_iterator it = mAudioSession->mParticipantsByUUID.begin(), + it_end = mAudioSession->mParticipantsByUUID.end(); + for (; it != it_end; ++it) + { + participant_uuids.insert((*(*it).first)); + } +} LLVoiceClient::participantState *LLVoiceClient::sessionState::findParticipant(const std::string &uri) { diff --git a/indra/newview/llvoiceclient.h b/indra/newview/llvoiceclient.h index 724179847d..6231c6ba29 100644 --- a/indra/newview/llvoiceclient.h +++ b/indra/newview/llvoiceclient.h @@ -354,6 +354,7 @@ static void updatePosition(void); participantState *findParticipantByID(const LLUUID& id); participantMap *getParticipantList(void); + void getParticipantsUUIDSet(std::set<LLUUID>& participant_uuids); typedef std::map<const std::string*, sessionState*, stringMapComparitor> sessionMap; typedef std::set<sessionState*> sessionSet; |