From 3ec9f79f0782539659963f159f6b94c86d1ebd7b Mon Sep 17 00:00:00 2001
From: Lynx Linden <lynx@lindenlab.com>
Date: Mon, 2 Nov 2009 15:51:55 +0000
Subject: [PATCH] DEV-40702: fixed the audio device enumeration code so that it
 works with Vivox V2 and V3 SDKs. We were assuming that the <CaptureDevice>
 tag contains only a single tag (<Device>), but the V3 SDK returns other tags
 such as <DisplayName> and <Type>.

I also added the current Vivox SDK version to the About window so that
it is easier to tell which version your client is actually using.
---
 indra/newview/llfloaterabout.cpp              |  2 ++
 indra/newview/llvoiceclient.cpp               | 33 ++++++++++---------
 indra/newview/llvoiceclient.h                 |  5 +++
 .../skins/default/xui/en/floater_about.xml    |  1 +
 4 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/indra/newview/llfloaterabout.cpp b/indra/newview/llfloaterabout.cpp
index 63ea990d14..88658f7b9f 100644
--- a/indra/newview/llfloaterabout.cpp
+++ b/indra/newview/llfloaterabout.cpp
@@ -39,6 +39,7 @@
 #include "llagent.h"
 #include "llappviewer.h" 
 #include "llsecondlifeurls.h"
+#include "llvoiceclient.h"
 #include "lluictrlfactory.h"
 #include "llviewertexteditor.h"
 #include "llviewercontrol.h"
@@ -268,6 +269,7 @@ LLSD LLFloaterAbout::getInfo()
 	info["J2C_VERSION"] = LLImageJ2C::getEngineInfo();
 	bool want_fullname = true;
 	info["AUDIO_DRIVER_VERSION"] = gAudiop ? LLSD(gAudiop->getDriverName(want_fullname)) : LLSD();
+	info["VIVOX_VERSION"] = gVoiceClient ? gVoiceClient->getAPIVersion() : "Unknown";
 
 	// TODO: Implement media plugin version query
 	info["QT_WEBKIT_VERSION"] = "4.5.2";
diff --git a/indra/newview/llvoiceclient.cpp b/indra/newview/llvoiceclient.cpp
index 2834284a9b..df5481c874 100644
--- a/indra/newview/llvoiceclient.cpp
+++ b/indra/newview/llvoiceclient.cpp
@@ -254,6 +254,7 @@ protected:
 	std::string		nameString;
 	std::string		audioMediaString;
 	std::string		displayNameString;
+	std::string		deviceString;
 	int				participantType;
 	bool			isLocallyMuted;
 	bool			isModeratorMuted;
@@ -485,6 +486,14 @@ void LLVivoxProtocolParser::StartTag(const char *tag, const char **attr)
 			{
 				gVoiceClient->clearRenderDevices();
 			}
+			else if (!stricmp("CaptureDevice", tag))
+			{
+				deviceString.clear();
+			}
+			else if (!stricmp("RenderDevice", tag))
+			{
+				deviceString.clear();
+			}
 			else if (!stricmp("Buddies", tag))
 			{
 				gVoiceClient->deleteAllBuddies();
@@ -508,7 +517,6 @@ void LLVivoxProtocolParser::StartTag(const char *tag, const char **attr)
 void LLVivoxProtocolParser::EndTag(const char *tag)
 {
 	const std::string& string = textBuffer;
-	bool clearbuffer = true;
 
 	responseDepth--;
 
@@ -580,6 +588,8 @@ void LLVivoxProtocolParser::EndTag(const char *tag)
 			nameString = string;
 		else if (!stricmp("DisplayName", tag))
 			displayNameString = string;
+		else if (!stricmp("Device", tag))
+			deviceString = string;
 		else if (!stricmp("AccountName", tag))
 			nameString = string;
 		else if (!stricmp("ParticipantType", tag))
@@ -596,18 +606,13 @@ void LLVivoxProtocolParser::EndTag(const char *tag)
 			uriString = string;
 		else if (!stricmp("Presence", tag))
 			statusString = string;
-		else if (!stricmp("Device", tag))
-		{
-			// This closing tag shouldn't clear the accumulated text.
-			clearbuffer = false;
-		}
 		else if (!stricmp("CaptureDevice", tag))
 		{
-			gVoiceClient->addCaptureDevice(textBuffer);
+			gVoiceClient->addCaptureDevice(deviceString);
 		}
 		else if (!stricmp("RenderDevice", tag))
 		{
-			gVoiceClient->addRenderDevice(textBuffer);
+			gVoiceClient->addRenderDevice(deviceString);
 		}
 		else if (!stricmp("Buddy", tag))
 		{
@@ -648,12 +653,8 @@ void LLVivoxProtocolParser::EndTag(const char *tag)
 		else if (!stricmp("SubscriptionType", tag))
 			subscriptionType = string;
 		
-
-		if(clearbuffer)
-		{
-			textBuffer.clear();
-			accumulateText= false;
-		}
+		textBuffer.clear();
+		accumulateText= false;
 		
 		if (responseDepth == 0)
 		{
@@ -1160,7 +1161,8 @@ LLVoiceClient::LLVoiceClient() :
 	mVoiceEnabled(false),
 	mWriteInProgress(false),
 	
-	mLipSyncEnabled(false)
+	mLipSyncEnabled(false),
+	mAPIVersion("Unknown")
 {	
 	gVoiceClient = this;
 	
@@ -3749,6 +3751,7 @@ void LLVoiceClient::connectorCreateResponse(int statusCode, std::string &statusS
 	{
 		// Connector created, move forward.
 		LL_INFOS("Voice") << "Connector.Create succeeded, Vivox SDK version is " << versionID << LL_ENDL;
+		mAPIVersion = versionID;
 		mConnectorHandle = connectorHandle;
 		if(getState() == stateConnectorStarting)
 		{
diff --git a/indra/newview/llvoiceclient.h b/indra/newview/llvoiceclient.h
index bddd18dee8..9df96d9a52 100644
--- a/indra/newview/llvoiceclient.h
+++ b/indra/newview/llvoiceclient.h
@@ -204,6 +204,9 @@ static	void updatePosition(void);
 		void keyDown(KEY key, MASK mask);
 		void keyUp(KEY key, MASK mask);
 		void middleMouseState(bool down);
+
+		// Return the version of the Vivox library
+		std::string getAPIVersion() const { return mAPIVersion; }
 		
 		/////////////////////////////
 		// Accessors for data related to nearby speakers
@@ -739,6 +742,8 @@ static	std::string nameFromsipURI(const std::string &uri);
 		
 		BOOL		mLipSyncEnabled;
 
+		std::string	mAPIVersion;
+
 		typedef std::set<LLVoiceClientParticipantObserver*> observer_set_t;
 		observer_set_t mParticipantObservers;
 
diff --git a/indra/newview/skins/default/xui/en/floater_about.xml b/indra/newview/skins/default/xui/en/floater_about.xml
index 02c6ed1b20..3f2636ae52 100644
--- a/indra/newview/skins/default/xui/en/floater_about.xml
+++ b/indra/newview/skins/default/xui/en/floater_about.xml
@@ -49,6 +49,7 @@ libcurl Version: [LIBCURL_VERSION]
 J2C Decoder Version: [J2C_VERSION]
 Audio Driver Version: [AUDIO_DRIVER_VERSION]
 Qt Webkit Version: [QT_WEBKIT_VERSION]
+Vivox Version: [VIVOX_VERSION]
 </floater.string>
   <floater.string
      name="none">
-- 
GitLab