From 7d38f4940c39b217bcf6b90b7811933099916de9 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 22 May 2013 20:01:57 +0100
Subject: Implement llSetSoundQueueing().

This is controlled by the viewer, not the server.
So as per http://wiki.secondlife.com/wiki/LlSetSoundQueueing, only two sounds can be queued per prim.
You probably need to use llPreloadSound() for best results
---
 OpenSim/Region/CoreModules/World/Sound/SoundModule.cs        |  9 +++++++++
 OpenSim/Region/Framework/Interfaces/ISoundModule.cs          |  8 +++++++-
 OpenSim/Region/Framework/Scenes/SceneObjectPart.cs           | 10 +++++++++-
 .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 12 ++++++++----
 4 files changed, 33 insertions(+), 6 deletions(-)

diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
index 883045a..d093224 100644
--- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
@@ -369,6 +369,15 @@ namespace OpenSim.Region.CoreModules.World.Sound
             });
         }
 
+        public void SetSoundQueueing(UUID objectID, bool shouldQueue)
+        {
+            SceneObjectPart part;
+            if (!m_scene.TryGetSceneObjectPart(objectID, out part))
+                return;
+
+            part.SoundQueueing = shouldQueue;
+        }
+
         #endregion
     }
 }
diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs
index 68af492..8372ddd 100644
--- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs
@@ -104,7 +104,6 @@ namespace OpenSim.Region.Framework.Interfaces
         /// <param name="sound">Sound asset ID</param>
         /// <param name="volume">Sound volume</param>
         /// <param name="triggered">Triggered or not.</param>
-        /// <param name="flags"></param>
         /// <param name="radius">Sound radius</param>
         /// <param name="useMaster">Play using sound master</param>
         /// <param name="isMaster">Play as sound master</param>
@@ -123,5 +122,12 @@ namespace OpenSim.Region.Framework.Interfaces
         /// <param name="max">AABB top north-east corner</param>
         void TriggerSoundLimited(UUID objectID, UUID sound, double volume,
                 Vector3 min, Vector3 max);
+
+        /// <summary>
+        /// Set whether sounds on the given prim should be queued.
+        /// </summary>
+        /// <param name='objectID'></param>
+        /// <param name='shouldQueue'></param>
+        void SetSoundQueueing(UUID objectID, bool shouldQueue);
     }
 }
\ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 347a2b5..b1c1cbb 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -219,6 +219,14 @@ namespace OpenSim.Region.Framework.Scenes
 
         public double SoundRadius;
 
+        /// <summary>
+        /// Should sounds played from this prim be queued?
+        /// </summary>
+        /// <remarks>
+        /// This should only be changed by sound modules.  It is up to sound modules as to how they interpret this setting.
+        /// </remarks>
+        public bool SoundQueueing { get; set; }
+
         public uint TimeStampFull;
 
         public uint TimeStampLastActivity; // Will be used for AutoReturn
@@ -2429,7 +2437,7 @@ namespace OpenSim.Region.Framework.Scenes
                 if (soundModule != null)
                 {
                     soundModule.SendSound(UUID, CollisionSound,
-                            CollisionSoundVolume, true, (byte)0, 0, false,
+                            CollisionSoundVolume, true, 0, 0, false,
                             false);
                 }
             }
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 969243c..0b4b043 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2474,9 +2474,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
             // send the sound, once, to all clients in range
             if (m_SoundModule != null)
             {
-                m_SoundModule.SendSound(m_host.UUID,
-                        ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), volume, false, 0,
-                        0, false, false);
+                m_SoundModule.SendSound(
+                    m_host.UUID,
+                    ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), 
+                    volume, false, m_host.SoundQueueing ? (byte)SoundFlags.Queue : (byte)SoundFlags.None,
+                    0, false, false);
             }
         }
 
@@ -11822,7 +11824,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
         public void llSetSoundQueueing(int queue)
         {
             m_host.AddScriptLPS(1);
-            NotImplemented("llSetSoundQueueing");
+
+            if (m_SoundModule != null)
+                m_SoundModule.SetSoundQueueing(m_host.UUID, queue == ScriptBaseClass.TRUE.value);
         }
 
         public void llCollisionSprite(string impact_sprite)
-- 
cgit v1.1