diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs
index 670794d94a..0225d6f77b 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 45219eddd3..0f6576345a 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 b333a1a5af..48615decc9 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 25be3ffa4f..61fd1aa552 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);
}