From 29a8ae48b51de55a02f839b6e4566054ad3f7f58 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Sat, 6 Oct 2012 22:23:14 +0100 Subject: [PATCH] transposing LoopSoundMaster to Sound Module --- .../World/Sound/SoundModuleNonShared.cs | 36 +++++++++++++++++++ .../Framework/Interfaces/ISoundModule.cs | 11 ++++++ .../Shared/Api/Implementation/LSL_Api.cs | 28 ++------------- 3 files changed, 50 insertions(+), 25 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index 0225d6f77b..4912ed8361 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -243,6 +243,42 @@ namespace OpenSim.Region.CoreModules.World.Sound }); } + public virtual void LoopSoundMaster(UUID objectID, UUID soundID, + double volume, double radius) + { + SceneObjectPart m_host; + if (!m_scene.TryGetSceneObjectPart(objectID, out m_host)) + return; + + m_host.ParentGroup.LoopSoundMasterPrim = m_host; + lock (m_host.ParentGroup.LoopSoundSlavePrims) + { + foreach (SceneObjectPart prim in m_host.ParentGroup.LoopSoundSlavePrims) + { + if (prim.Sound != UUID.Zero) + StopSound(objectID); + + prim.Sound = soundID; + prim.SoundGain = volume; + prim.SoundFlags = 1; // looping + prim.SoundRadius = radius; + + prim.ScheduleFullUpdate(); + prim.SendFullUpdateToAllClients(); + } + } + if (m_host.Sound != UUID.Zero) + StopSound(objectID); + + m_host.Sound = soundID; + m_host.SoundGain = volume; + m_host.SoundFlags = 1; // looping + m_host.SoundRadius = radius; + + m_host.ScheduleFullUpdate(); + m_host.SendFullUpdateToAllClients(); + } + #endregion } } diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs index 0f6576345a..d2557b59fa 100644 --- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs @@ -84,5 +84,16 @@ namespace OpenSim.Region.Framework.Interfaces /// Radius used to determine which viewers should preload the sound. /// void PreloadSound(UUID soundID, UUID objectID, float radius); + + /// + /// Declare object as new sync master, play specified sound at + /// specified volume with specified radius. + /// + /// Sound source ID + /// Sound asset ID + /// Sound volume + /// Sound radius + void LoopSoundMaster(UUID objectID, UUID soundID, double gain, + double radius); } } \ No newline at end of file diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 61fd1aa552..2669add8f8 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2397,33 +2397,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public void llLoopSoundMaster(string sound, double volume) { m_host.AddScriptLPS(1); - m_host.ParentGroup.LoopSoundMasterPrim = m_host; - lock (m_host.ParentGroup.LoopSoundSlavePrims) + if (m_SoundModule != null) { - foreach (SceneObjectPart prim in m_host.ParentGroup.LoopSoundSlavePrims) - { - if (prim.Sound != UUID.Zero) - llStopSound(); - - prim.Sound = KeyOrName(sound); - prim.SoundGain = volume; - prim.SoundFlags = 1; // looping - prim.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable? - - prim.ScheduleFullUpdate(); - prim.SendFullUpdateToAllClients(); - } + m_SoundModule.LoopSoundMaster(m_host.UUID, KeyOrName(sound), + volume, 20); } - if (m_host.Sound != UUID.Zero) - llStopSound(); - - m_host.Sound = KeyOrName(sound); - m_host.SoundGain = volume; - m_host.SoundFlags = 1; // looping - m_host.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable? - - m_host.ScheduleFullUpdate(); - m_host.SendFullUpdateToAllClients(); } public void llLoopSoundSlave(string sound, double volume)