From dd861135677b54a797305bb92199ac614cae5070 Mon Sep 17 00:00:00 2001
From: Rick Pasetto <rick@lindenlab.com>
Date: Mon, 11 Jan 2010 10:03:00 -0800
Subject: [PATCH] Backed out changeset b6030bb6ff40

---
 indra/newview/llviewermedia.cpp       | 73 +++++++++++++++++++++++++++
 indra/newview/llviewermedia.h         |  6 +++
 indra/newview/llviewerparcelmedia.cpp | 40 +--------------
 3 files changed, 81 insertions(+), 38 deletions(-)

diff --git a/indra/newview/llviewermedia.cpp b/indra/newview/llviewermedia.cpp
index 7e8c8eb92ed..f91d1260732 100644
--- a/indra/newview/llviewermedia.cpp
+++ b/indra/newview/llviewermedia.cpp
@@ -54,6 +54,7 @@
 #include "lluuid.h"
 #include "llkeyboard.h"
 #include "llmutelist.h"
+#include "llfirstuse.h"
 
 #include <boost/bind.hpp>	// for SkinFolder listener
 #include <boost/signals2.hpp>
@@ -708,6 +709,8 @@ void LLViewerMedia::updateMedia(void *dummy_arg)
 	
 	std::vector<LLViewerMediaImpl*> proximity_order;
 	
+	bool inworld_media_enabled = gSavedSettings.getBOOL("AudioStreamingMedia");
+	bool needs_first_run = LLViewerMedia::needsMediaFirstRun();
 	U32 max_instances = gSavedSettings.getU32("PluginInstancesTotal");
 	U32 max_normal = gSavedSettings.getU32("PluginInstancesNormal");
 	U32 max_low = gSavedSettings.getU32("PluginInstancesLow");
@@ -822,6 +825,21 @@ void LLViewerMedia::updateMedia(void *dummy_arg)
 			new_priority = LLPluginClassMedia::PRIORITY_LOW;
 		}
 		
+		if(!inworld_media_enabled)
+		{
+			// If inworld media is locked out, force all inworld media to stay unloaded.
+			if(!pimpl->getUsedInUI())
+			{
+				new_priority = LLPluginClassMedia::PRIORITY_UNLOADED;
+				if(needs_first_run)
+				{
+					// Don't do this more than once in this loop.
+					needs_first_run = false;
+					LLViewerMedia::displayMediaFirstRun();
+				}
+			}
+		}
+		
 		pimpl->setPriority(new_priority);
 		
 		if(pimpl->getUsedInUI())
@@ -888,6 +906,61 @@ void LLViewerMedia::cleanupClass()
 	gIdleCallbacks.deleteFunction(LLViewerMedia::updateMedia, NULL);
 }
 
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// static
+bool LLViewerParcelMedia::needsMediaFirstRun()
+{
+	return gWarningSettings.getBOOL("FirstStreamingMedia");
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// static
+void LLViewerParcelMedia::displayMediaFirstRun()
+{
+	gWarningSettings.setBOOL("FirstStreamingMedia", FALSE);
+
+	LLNotificationsUtil::add("ParcelCanPlayMedia", LLSD(), LLSD(),
+		boost::bind(firstRunCallback, _1, _2));
+}
+
+//////////////////////////////////////////////////////////////////////////////////////////
+// static
+bool LLViewerParcelMedia::firstRunCallback(const LLSD& notification, const LLSD& response)
+{
+	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
+	if (option == 0)
+	{
+		// user has elected to automatically play media.
+		gSavedSettings.setBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING, TRUE);
+		gSavedSettings.setBOOL("AudioStreamingVideo", TRUE);
+		gSavedSettings.setBOOL("AudioStreamingMusic", TRUE);
+		gSavedSettings.setBOOL("AudioStreamingMedia", TRUE);
+
+		LLParcel *parcel = LLViewerParcelMgr::getInstance()->getAgentParcel();
+				
+		if (parcel)
+		{
+			// play media right now, if available
+			LLViewerParcelMedia::play(parcel);
+		
+			// play music right now, if available
+			std::string music_url = parcel->getMusicURL();
+			if (gAudiop && !music_url.empty())
+				gAudiop->startInternetStream(music_url);
+		}
+	}
+	else
+	{
+		gSavedSettings.setBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING, FALSE);
+		gSavedSettings.setBOOL("AudioStreamingMedia", FALSE);
+		gSavedSettings.setBOOL("AudioStreamingVideo", FALSE);
+		gSavedSettings.setBOOL("AudioStreamingMusic", FALSE);
+	}
+	return false;
+}
+
+
 //////////////////////////////////////////////////////////////////////////////////////////
 // LLViewerMediaImpl
 //////////////////////////////////////////////////////////////////////////////////////////
diff --git a/indra/newview/llviewermedia.h b/indra/newview/llviewermedia.h
index b103c48bd85..3ce9f1887cf 100644
--- a/indra/newview/llviewermedia.h
+++ b/indra/newview/llviewermedia.h
@@ -115,6 +115,12 @@ class LLViewerMedia
 		
 		// This is the comparitor used to sort the list.
 		static bool priorityComparitor(const LLViewerMediaImpl* i1, const LLViewerMediaImpl* i2);
+		
+		// For displaying the media first-run dialog.
+		static bool needsMediaFirstRun();
+		static void displayMediaFirstRun();
+		static bool firstRunCallback(const LLSD& notification, const LLSD& response);
+
 };
 
 // Implementation functions not exported into header file
diff --git a/indra/newview/llviewerparcelmedia.cpp b/indra/newview/llviewerparcelmedia.cpp
index 0f7903a7a53..56dee6b34c7 100644
--- a/indra/newview/llviewerparcelmedia.cpp
+++ b/indra/newview/llviewerparcelmedia.cpp
@@ -56,10 +56,6 @@ LLUUID LLViewerParcelMedia::sMediaRegionID;
 viewer_media_t LLViewerParcelMedia::sMediaImpl;
 
 
-// Local functions
-bool callback_play_media(const LLSD& notification, const LLSD& response, LLParcel* parcel);
-
-
 // static
 void LLViewerParcelMedia::initClass()
 {
@@ -112,12 +108,10 @@ void LLViewerParcelMedia::update(LLParcel* parcel)
 			// First use warning
 			if( (!mediaUrl.empty() ||
 			     !parcel->getMusicURL().empty())
-			    && gWarningSettings.getBOOL("FirstStreamingMedia") )
+			    && LLViewerMedia::needsMediaFirstRun())
 			{
-				LLNotificationsUtil::add("ParcelCanPlayMedia", LLSD(), LLSD(),
-					boost::bind(callback_play_media, _1, _2, parcel));
+				LLViewerMedia::displayMediaFirstRun();
 				return;
-
 			}
 
 			// if we have a current (link sharing) url, use it instead
@@ -591,36 +585,6 @@ void LLViewerParcelMedia::handleMediaEvent(LLPluginClassMedia* self, EMediaEvent
 	};
 }
 
-bool callback_play_media(const LLSD& notification, const LLSD& response, LLParcel* parcel)
-{
-	S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
-	if (option == 0)
-	{
-		// user has elected to automatically play media.
-		gSavedSettings.setBOOL(LLViewerMedia::AUTO_PLAY_MEDIA_SETTING, TRUE);
-		gSavedSettings.setBOOL("AudioStreamingVideo", TRUE);
-		gSavedSettings.setBOOL("AudioStreamingMusic", TRUE);
-		if(!gSavedSettings.getBOOL("AudioStreamingMedia")) 
-			gSavedSettings.setBOOL("AudioStreamingMedia", TRUE);
-		// play media right now, if available
-		LLViewerParcelMedia::play(parcel);
-		// play music right now, if available
-		if (parcel)
-		{
-			std::string music_url = parcel->getMusicURL();
-			if (gAudiop && !music_url.empty())
-				gAudiop->startInternetStream(music_url);
-		}
-	}
-	else
-	{
-		gSavedSettings.setBOOL("AudioStreamingVideo", FALSE);
-		gSavedSettings.setBOOL("AudioStreamingMusic", FALSE);
-	}
-	gWarningSettings.setBOOL("FirstStreamingMedia", FALSE);
-	return false;
-}
-
 // TODO: observer
 /*
 void LLViewerParcelMediaNavigationObserver::onNavigateComplete( const EventType& event_in )
-- 
GitLab