From a68e2fe1692a7611c58f774ac5b94c4298343433 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Fri, 5 Oct 2012 15:16:30 +0100 Subject: transposing preload sound onto sound module --- .../World/Sound/SoundModuleNonShared.cs | 20 ++++++++++++++ .../Region/Framework/Interfaces/ISoundModule.cs | 10 +++++++ OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 31 ---------------------- .../Shared/Api/Implementation/LSL_Api.cs | 3 ++- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index 670794d..0225d6f 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ using System; +using System.Collections.Generic; using System.Reflection; using Nini.Config; @@ -223,6 +224,25 @@ namespace OpenSim.Region.CoreModules.World.Sound } } + public virtual void PreloadSound(UUID soundID, UUID objectID, float radius) + { + SceneObjectPart part; + if (soundID == UUID.Zero + || !m_scene.TryGetSceneObjectPart(objectID, out part)) + { + return; + } + + if (radius == 0) + radius = MaxDistance; + + m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) + { + if (!(Util.GetDistanceTo(sp.AbsolutePosition, part.AbsolutePosition) >= MaxDistance)) + sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); + }); + } + #endregion } } diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs index 45219ed..0f65763 100644 --- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs @@ -74,5 +74,15 @@ namespace OpenSim.Region.Framework.Interfaces /// /// Sound source ID void StopSound(UUID objectID); + + /// + /// Preload sound to viewers within range. + /// + /// Sound asset ID + /// Sound source ID + /// + /// Radius used to determine which viewers should preload the sound. + /// + void PreloadSound(UUID soundID, UUID objectID, float radius); } } \ No newline at end of file diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index b333a1a..48615de 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -2287,37 +2287,6 @@ namespace OpenSim.Region.Framework.Scenes ScheduleTerseUpdate(); } - public void PreloadSound(string sound) - { - // UUID ownerID = OwnerID; - UUID objectID = ParentGroup.RootPart.UUID; - UUID soundID = UUID.Zero; - - if (!UUID.TryParse(sound, out soundID)) - { - //Trys to fetch sound id from prim's inventory. - //Prim's inventory doesn't support non script items yet - - lock (TaskInventory) - { - foreach (KeyValuePair item in TaskInventory) - { - if (item.Value.Name == sound) - { - soundID = item.Value.ItemID; - break; - } - } - } - } - - ParentGroup.Scene.ForEachRootScenePresence(delegate(ScenePresence sp) - { - if (!(Util.GetDistanceTo(sp.AbsolutePosition, AbsolutePosition) >= 100)) - sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); - }); - } - public void RemFlag(PrimFlags flag) { // PrimFlags prevflag = Flags; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 25be3ff..61fd1aa 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2461,7 +2461,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llPreloadSound(string sound) { m_host.AddScriptLPS(1); - m_host.PreloadSound(sound); + if (m_SoundModule != null) + m_SoundModule.PreloadSound(KeyOrName(sound), m_host.UUID, 0); ScriptSleep(1000); } -- cgit v1.1