Anonymous avatar Anonymous committed c13cda3

EXT-7138 WIP Simplify and improve detection and notification of changes to the Voice font list

Comments (0)

Files changed (2)

indra/newview/llvoicevivox.cpp

 
 	mVoiceFontsReceived(false),
 	mVoiceFontsNew(false),
+	mVoiceFontListDirty(false),
 
 	mCaptureBufferMode(false),
 	mCaptureBufferRecording(false),
 			mCaptureTimer.setTimerExpirySec(CAPTURE_BUFFER_MAX_TIME);
 
 			// Update UI, should really use a separate callback.
-			notifyVoiceFontObservers(false);
+			notifyVoiceFontObservers();
 
 			setState(stateCaptureBufferRecording);
 		break;
 				mCaptureBufferRecording = false;
 
 				// Update UI, should really use a separate callback.
-				notifyVoiceFontObservers(false);
+				notifyVoiceFontObservers();
 
 				setState(stateCaptureBufferPaused);
 			}
 			mPreviewVoiceFontLast = mPreviewVoiceFont;
 
 			// Update UI, should really use a separate callback.
-			notifyVoiceFontObservers(false);
+			notifyVoiceFontObservers();
 
 			setState(stateCaptureBufferPlaying);
 		break;
 				mCaptureBufferPlaying = false;
 
 				// Update UI, should really use a separate callback.
-				notifyVoiceFontObservers(false);
+				notifyVoiceFontObservers();
 
 				setState(stateCaptureBufferPaused);
 			}
 	{
 		mAudioSessionChanged = false;
 		notifyParticipantObservers();
-		notifyVoiceFontObservers(false);
+		notifyVoiceFontObservers();
 	}
 	else if (mAudioSession && mAudioSession->mParticipantsChanged)
 	{
 	gSavedPerAccountSettings.setString("VoiceEffectDefault", id.asString());
 
 	sessionSetVoiceFontSendMessage(mAudioSession);
-	notifyVoiceFontObservers(false);
+	notifyVoiceFontObservers();
 
 	return true;
 }
 	voice_font_map_t::iterator iter = font_map.find(font_id);
 	bool new_font = (iter == font_map.end());
 
+	if (has_expired)
+	{
+		// Remove existing session fonts that have expired since we last saw them.
+		if (!new_font)
+		{
+			LL_DEBUGS("Voice") << "Expired " << (template_font ? "Template " : "")
+			<< expiration_date.asString() << " " << font_id
+			<< " (" << font_index << ") " << name << LL_ENDL;
+
+			if (!template_font)
+			{
+				deleteVoiceFont(font_id);
+			}
+		}
+		return;
+	}
+
 	if (new_font)
 	{
-		if (has_expired)
-		{
-			// If it's new and already marked expired, ignore it.
-			return;
-		}
-
-		// If it is a new (unexpired) font create a new entry.
+		// If it is a new font create a new entry.
 		font = new voiceFontEntry(font_id);
 	}
 	else
 
 	if (font)
 	{
-		// Remove existing fonts that have expired since we last saw them.
-		if (has_expired)
-		{
-			LL_DEBUGS("Voice") << "Expired " << (template_font ? "Template: " : ":")
-				<< font->mExpirationDate.asString() << font_id
-				<< " (" << font_index << ") " << name << LL_ENDL;
-
-			if (!template_font)
-			{
-				deleteVoiceFont(font_id);
-			}
-			return;
-		}
-
 		font->mFontIndex = font_index;
 		// Use the description for the human readable name if available, as the
 		// "name" may be a UUID.
 		font->mFontType = font_type;
 		font->mFontStatus = font_status;
 
-		LL_DEBUGS("Voice") << (template_font ? "Template: " : "")
-			<< font->mExpirationDate.asString() << font->mID
+		LL_DEBUGS("Voice") << (template_font ? "Template " : "")
+			<< font->mExpirationDate.asString() << " " << font->mID
 			<< " (" << font->mFontIndex << ") " << name << LL_ENDL;
 
 		// Set the expiry timer to trigger a notification when the voice font can no longer be used.
 			font->mExpiryWarningTimer.stop();
 		}
 
-		 // Only flag it as a new font if we have already seen the font list.
+		 // Only flag new session fonts.
 		if (!template_font && mVoiceFontsReceived && new_font)
 		{
 			font->mIsNew = true;
 			font_list.insert(voice_effect_list_t::value_type(font->mName, font->mID));
 		}
 
+		mVoiceFontListDirty = true;
+
 		// Debugging stuff
 
 		if (font_type < VOICE_FONT_TYPE_NONE || font_type >= VOICE_FONT_TYPE_UNKNOWN)
 		}
 
 		// Refresh voice font lists in the UI.
-		notifyVoiceFontObservers(true);
+		notifyVoiceFontObservers();
 	}
 
 	// Give a warning notification if any voice fonts are due to expire.
 		{
 			LL_DEBUGS("Voice") << "Removing " << id << " from the voice font list." << LL_ENDL;
 			mVoiceFontList.erase(list_iter++);
+			mVoiceFontListDirty = true;
 		}
 		else
 		{
 	{
 		setState(stateVoiceFontsReceived);
 	}
+
+	notifyVoiceFontObservers();
 	mVoiceFontsReceived = true;
-
-	// If new Voice Fonts have been found notify the user.
-	if (mVoiceFontsNew)
-	{
-		LLNotificationsUtil::add("VoiceEffectsNew");
-		mVoiceFontsNew = false;
-	}
-
-	notifyVoiceFontObservers(true);
 }
 
 void LLVivoxVoiceClient::accountGetTemplateFontsResponse(int statusCode, const std::string &statusString)
 {
 	// Voice font list entries were updated via addVoiceFont() during parsing.
-	notifyVoiceFontObservers(true);
+	notifyVoiceFontObservers();
 }
 void LLVivoxVoiceClient::addObserver(LLVoiceEffectObserver* observer)
 {
 	mVoiceFontObservers.erase(observer);
 }
 
-void LLVivoxVoiceClient::notifyVoiceFontObservers(bool lists_changed)
-{
-	LL_DEBUGS("Voice") << "Notifying voice effect observers. Lists changed: " << lists_changed << LL_ENDL;
+void LLVivoxVoiceClient::notifyVoiceFontObservers()
+{
+	LL_DEBUGS("Voice") << "Notifying voice effect observers. Lists changed: " << mVoiceFontListDirty << LL_ENDL;
 
 	for (voice_font_observer_set_t::iterator it = mVoiceFontObservers.begin();
 		 it != mVoiceFontObservers.end();
 		 )
 	{
 		LLVoiceEffectObserver* observer = *it;
-		observer->onVoiceEffectChanged(lists_changed);
+		observer->onVoiceEffectChanged(mVoiceFontListDirty);
 		// In case onVoiceEffectChanged() deleted an entry.
 		it = mVoiceFontObservers.upper_bound(observer);
 	}
+	mVoiceFontListDirty = false;
+
+	// If new Voice Fonts have been added notify the user.
+	if (mVoiceFontsNew)
+	{
+		if(mVoiceFontsReceived)
+		{
+			LLNotificationsUtil::add("VoiceEffectsNew");
+		}
+		mVoiceFontsNew = false;
+	}
 }
 
 void LLVivoxVoiceClient::enablePreviewBuffer(bool enable)
 	std::string time_stamp = vivox_ts;
 
 	// Vivox's format is missing a T from being standard ISO 8601,
-	// so add it.  It is the only space in their result.
+	// so add it instead of the only space after the date.
 	LLStringUtil::replaceChar(time_stamp, ' ', 'T');
 
-	// Also need to remove the hours away from GMT to be compatible
-	// with LLDate, as well as the fractions of seconds.
-	time_stamp = time_stamp.substr(0, time_stamp.length() - 5);
-
-	// It also needs a 'Z' at the end
+	// LLDate can't handle offsets from UTC, so remove it, and add a Z
+	time_stamp = time_stamp.substr(0, time_stamp.length() - 3);
 	time_stamp += "Z";
 
 	ts.fromString(time_stamp);

indra/newview/llvoicevivox.h

 	void accountGetTemplateFontsSendMessage();
 	void sessionSetVoiceFontSendMessage(sessionState *session);
 
-	void notifyVoiceFontObservers(bool lists_changed = false);
+	void notifyVoiceFontObservers();
 
 	typedef enum e_voice_font_type
 	{
 
 	bool mVoiceFontsReceived;
 	bool mVoiceFontsNew;
+	bool mVoiceFontListDirty;
 	voice_effect_list_t	mVoiceFontList;
 	voice_effect_list_t	mVoiceFontTemplateList;
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.