Work on major bug EXT-3976 (Voice chat speaking indicators should only display when users are in the same voice channel)

-- improvements: replace std::vector with std::set to avoid duplicated speaker UUIDs. Added method to get a set of voice participants UUIDs

--HG--
branch : product-engine
meow-7.2.2
Mike Antipov 2010-01-14 18:24:38 +02:00
parent 2029bf92e2
commit fc633fce71
3 changed files with 19 additions and 42 deletions

View File

@ -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

View File

@ -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)
{

View File

@ -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;