From 9df510157e26ffcaf04fd4b85512778fddc08f68 Mon Sep 17 00:00:00 2001 From: SignpostMarv Date: Mon, 15 Oct 2012 14:28:34 +0100 Subject: deduplicating code into a single LoopSound method --- .../World/Sound/SoundModuleNonShared.cs | 13 ++++++++-- .../Region/Framework/Interfaces/ISoundModule.cs | 9 +++---- .../Shared/Api/Implementation/LSL_Api.cs | 28 ++++++---------------- 3 files changed, 23 insertions(+), 27 deletions(-) diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs index b4b8e79..6f35a23 100644 --- a/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs +++ b/OpenSim/Region/CoreModules/World/Sound/SoundModuleNonShared.cs @@ -248,13 +248,22 @@ namespace OpenSim.Region.CoreModules.World.Sound }); } - public virtual void LoopSoundMaster(UUID objectID, UUID soundID, - double volume, double radius) + // Xantor 20080528 we should do this differently. + // 1) apply the sound to the object + // 2) schedule full update + // just sending the sound out once doesn't work so well when other avatars come in view later on + // or when the prim gets moved, changed, sat on, whatever + // see large number of mantises (mantes?) + // 20080530 Updated to remove code duplication + // 20080530 Stop sound if there is one, otherwise volume only changes don't work + public void LoopSound(UUID objectID, UUID soundID, + double volume, double radius, bool isMaster) { SceneObjectPart m_host; if (!m_scene.TryGetSceneObjectPart(objectID, out m_host)) return; + if (isMaster) m_host.ParentGroup.LoopSoundMasterPrim = m_host; if (m_host.Sound != UUID.Zero) diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs index d34a520..e514a59 100644 --- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs +++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs @@ -86,14 +86,15 @@ namespace OpenSim.Region.Framework.Interfaces void PreloadSound(UUID objectID, UUID soundID, float radius); /// - /// Declare object as new sync master, play specified sound at - /// specified volume with specified radius. + /// Loop specified sound at specified volume with specified radius, + /// optionally declaring object as new sync master. /// /// Sound source ID /// Sound asset ID /// Sound volume /// Sound radius - void LoopSoundMaster(UUID objectID, UUID soundID, double gain, - double radius); + /// Set object to sync master if true + void LoopSound(UUID objectID, UUID soundID, double gain, + double radius, bool isMaster); } } \ 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 0252145..c479944 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -2370,28 +2370,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0, 0, false, false); } - // Xantor 20080528 we should do this differently. - // 1) apply the sound to the object - // 2) schedule full update - // just sending the sound out once doesn't work so well when other avatars come in view later on - // or when the prim gets moved, changed, sat on, whatever - // see large number of mantises (mantes?) - // 20080530 Updated to remove code duplication - // 20080530 Stop sound if there is one, otherwise volume only changes don't work public void llLoopSound(string sound, double volume) { m_host.AddScriptLPS(1); - - 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(); + if (m_SoundModule != null) + { + m_SoundModule.LoopSound(m_host.UUID, KeyOrName(sound), + volume, 20, false); + } } public void llLoopSoundMaster(string sound, double volume) @@ -2399,8 +2385,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api m_host.AddScriptLPS(1); if (m_SoundModule != null) { - m_SoundModule.LoopSoundMaster(m_host.UUID, KeyOrName(sound), - volume, 20); + m_SoundModule.LoopSound(m_host.UUID, KeyOrName(sound), + volume, 20, true); } } -- cgit v1.1