From 4c6d743665ae39a6402ee7b86f43043cb4c5806d Mon Sep 17 00:00:00 2001
From: Aimee Linden <aimee@lindenlab.com>
Date: Wed, 19 May 2010 21:13:19 +0100
Subject: [PATCH] EXT-7337 WIP Voice font previewing Handle
 mediaCompletionEvents in the voice client to update UI when preview playback
 ends.

---
 indra/newview/llvoicevivox.cpp | 38 ++++++++++++++++++++++++++++++++--
 indra/newview/llvoicevivox.h   |  2 ++
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp
index 2df9152a17..7daf865151 100644
--- a/indra/newview/llvoicevivox.cpp
+++ b/indra/newview/llvoicevivox.cpp
@@ -3530,6 +3530,22 @@ void LLVivoxVoiceClient::accountLoginStateChangeEvent(
 	}
 }
 
+void LLVivoxVoiceClient::mediaCompletionEvent(std::string &sessionGroupHandle, std::string &mediaCompletionType)
+{
+	if (mediaCompletionType == "AuxBufferAudioCapture")
+	{
+		mCaptureBufferRecording = false;
+	}
+	else if (mediaCompletionType == "AuxBufferAudioRender")
+	{
+		mCaptureBufferPlaying = false;
+	}
+	else
+	{
+		LL_DEBUGS("Voice") << "Unknown MediaCompletionType: " << mediaCompletionType << LL_ENDL;
+	}
+}
+
 void LLVivoxVoiceClient::mediaStreamUpdatedEvent(
 	std::string &sessionHandle, 
 	std::string &sessionGroupHandle, 
@@ -7071,6 +7087,10 @@ void LLVivoxProtocolParser::StartTag(const char *tag, const char **attr)
 				fontType = 0;
 				fontStatus = 0;
 			}
+			else if (!stricmp("MediaCompletionType", tag))
+			{
+				mediaCompletionType.clear();
+			}
 		}
 	}
 	responseDepth++;
@@ -7248,7 +7268,11 @@ void LLVivoxProtocolParser::EndTag(const char *tag)
 		{
 			fontStatus = strtol(string.c_str(), NULL, 10);
 		}
-	
+		else if (!stricmp("MediaCompletionType", tag))
+		{
+			mediaCompletionType = string;;
+		}
+
 		textBuffer.clear();
 		accumulateText= false;
 		
@@ -7330,7 +7354,17 @@ void LLVivoxProtocolParser::processResponse(std::string tag)
 			 </Event>
 			 */
 			LLVivoxVoiceClient::getInstance()->mediaStreamUpdatedEvent(sessionHandle, sessionGroupHandle, statusCode, statusString, state, incoming);
-		}		
+		}
+		else if (!stricmp(eventTypeCstr, "MediaCompletionEvent"))
+		{
+			/*
+			<Event type="MediaCompletionEvent">
+			<SessionGroupHandle />
+			<MediaCompletionType>AuxBufferAudioCapture</MediaCompletionType>
+			</Event>
+			*/
+			LLVivoxVoiceClient::getInstance()->mediaCompletionEvent(sessionGroupHandle, mediaCompletionType);
+		}
 		else if (!stricmp(eventTypeCstr, "TextStreamUpdatedEvent"))
 		{
 			/*
diff --git a/indra/newview/llvoicevivox.h b/indra/newview/llvoicevivox.h
index 1047d2e5ed..5ba8082d56 100644
--- a/indra/newview/llvoicevivox.h
+++ b/indra/newview/llvoicevivox.h
@@ -499,6 +499,7 @@ protected:
 	void connectorShutdownResponse(int statusCode, std::string &statusString);
 
 	void accountLoginStateChangeEvent(std::string &accountHandle, int statusCode, std::string &statusString, int state);
+	void mediaCompletionEvent(std::string &sessionGroupHandle, std::string &mediaCompletionType);
 	void mediaStreamUpdatedEvent(std::string &sessionHandle, std::string &sessionGroupHandle, int statusCode, std::string &statusString, int state, bool incoming);
 	void textStreamUpdatedEvent(std::string &sessionHandle, std::string &sessionGroupHandle, bool enabled, int state, bool incoming);
 	void sessionAddedEvent(std::string &uriString, std::string &alias, std::string &sessionHandle, std::string &sessionGroupHandle, bool isChannel, bool incoming, std::string &nameString, std::string &applicationString);
@@ -1015,6 +1016,7 @@ protected:
 	bool			hasExpired;
 	S32				fontType;
 	S32				fontStatus;
+	std::string		mediaCompletionType;
 	
 	// Members for processing text between tags
 	std::string		textBuffer;
-- 
GitLab