From be0662234565f772fc4c89e47400dc9df8277800 Mon Sep 17 00:00:00 2001
From: Aimee Linden <aimee@lindenlab.com>
Date: Wed, 19 May 2010 16:25:52 +0100
Subject: [PATCH] EXT-7337 WIP Voice font previewing Added
 LLVoiceEffectInterface::getVoiceEffectProperties Added
 LLVivoxVoiceClient::getVoiceFontTemplateIndex

---
 indra/newview/llvoicevivox.cpp | 50 +++++++++++++++++++++++++++++++++-
 indra/newview/llvoicevivox.h   |  2 ++
 2 files changed, 51 insertions(+), 1 deletion(-)

diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp
index ee67879d3d..2df9152a17 100644
--- a/indra/newview/llvoicevivox.cpp
+++ b/indra/newview/llvoicevivox.cpp
@@ -6378,6 +6378,36 @@ const LLUUID LLVivoxVoiceClient::getVoiceEffect()
 	return mAudioSession ? mAudioSession->mVoiceFontID : LLUUID::null;
 }
 
+LLSD LLVivoxVoiceClient::getVoiceEffectProperties(const LLUUID& id)
+{
+	LLSD sd;
+
+	voice_font_map_t::iterator iter = mVoiceFontMap.find(id);
+	if (iter != mVoiceFontMap.end())
+	{
+		sd["template_only"] = false;
+	}
+	else
+	{
+		// Voice effect is not in the voice font map, see if there is a template
+		iter = mVoiceFontTemplateMap.find(id);
+		if (iter == mVoiceFontTemplateMap.end())
+		{
+			LL_WARNS("Voice") << "Voice effect " << id << "not found." << LL_ENDL;
+			return sd;
+		}
+		sd["template_only"] = true;
+	}
+
+	voiceFontEntry *font = iter->second;
+	sd["name"] = font->mName;
+	sd["expired"] = font->mHasExpired;
+	sd["expiry_date"] = font->mExpirationDate;
+	sd["is_new"] = font->mIsNew;
+
+	return sd;
+}
+
 LLVivoxVoiceClient::voiceFontEntry::voiceFontEntry(LLUUID& id) :
 	mID(id),
 	mFontIndex(0),
@@ -6536,6 +6566,24 @@ S32 LLVivoxVoiceClient::getVoiceFontIndex(const LLUUID& id) const
 	return result;
 }
 
+S32 LLVivoxVoiceClient::getVoiceFontTemplateIndex(const LLUUID& id) const
+{
+	S32 result = 0;
+	if (!id.isNull())
+	{
+		voice_font_map_t::const_iterator it = mVoiceFontTemplateMap.find(id);
+		if (it != mVoiceFontTemplateMap.end())
+		{
+			result = it->second->mFontIndex;
+		}
+		else
+		{
+			LL_DEBUGS("Voice") << "Selected voice font template " << id << " is not available." << LL_ENDL;
+		}
+	}
+	return result;
+}
+
 void LLVivoxVoiceClient::accountGetSessionFontsSendMessage()
 {
 	if(!mAccountHandle.empty())
@@ -6753,7 +6801,7 @@ void LLVivoxVoiceClient::captureBufferPlayStartSendMessage(const LLUUID& voice_f
 
 		LL_DEBUGS("Voice") << "Starting audio buffer playback." << LL_ENDL;
 
-		S32 font_index = getVoiceFontIndex(voice_font_id);
+		S32 font_index = getVoiceFontTemplateIndex(voice_font_id);
 		LL_DEBUGS("Voice") << "With voice font: " << voice_font_id << " (" << font_index << ")" << LL_ENDL;
 
 		stream
diff --git a/indra/newview/llvoicevivox.h b/indra/newview/llvoicevivox.h
index 6c302962a3..1047d2e5ed 100644
--- a/indra/newview/llvoicevivox.h
+++ b/indra/newview/llvoicevivox.h
@@ -240,6 +240,7 @@ public:
 	//@{
 	virtual bool setVoiceEffect(const LLUUID& id);
 	virtual const LLUUID getVoiceEffect();
+	virtual LLSD getVoiceEffectProperties(const LLUUID& id);
 
 	virtual void refreshVoiceEffectLists(bool clear_lists);
 	virtual const voice_effect_list_t& getVoiceEffectList() const;
@@ -859,6 +860,7 @@ private:
 	void deleteVoiceFontTemplates();
 
 	S32 getVoiceFontIndex(const LLUUID& id) const;
+	S32 getVoiceFontTemplateIndex(const LLUUID& id) const;
 
 	void accountGetSessionFontsSendMessage();
 	void accountGetTemplateFontsSendMessage();
-- 
GitLab