aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/CoreModules/World/Sound/SoundModule.cs149
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISoundModule.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs11
4 files changed, 66 insertions, 102 deletions
diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
index d093224..34253d5 100644
--- a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
+++ b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs
@@ -48,6 +48,18 @@ namespace OpenSim.Region.CoreModules.World.Sound
48 48
49 private Scene m_scene; 49 private Scene m_scene;
50 50
51 public enum SoundFlags: byte
52 {
53 NONE = 0,
54 LOOP = 1 << 0,
55 SYNC_MASTER = 1<<1,
56 SYNC_SLAVE = 1<<2,
57 SYNC_PENDING = 1<<3,
58 QUEUE = 1<<4,
59 STOP = 1<<5,
60 SYNC_MASK = SYNC_MASTER | SYNC_SLAVE | SYNC_PENDING
61 }
62
51 public bool Enabled { get; private set; } 63 public bool Enabled { get; private set; }
52 64
53 public float MaxDistance { get; private set; } 65 public float MaxDistance { get; private set; }
@@ -124,26 +136,19 @@ namespace OpenSim.Region.CoreModules.World.Sound
124 if (radius == 0) 136 if (radius == 0)
125 radius = MaxDistance; 137 radius = MaxDistance;
126 138
139 if (part.SoundQueueing)
140 flags |= (byte)SoundFlags.QUEUE;
141
127 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) 142 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
128 { 143 {
129 double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
130 if (dis > MaxDistance) // Max audio distance
131 return;
132
133 if (grp.IsAttachment) 144 if (grp.IsAttachment)
134 { 145 {
135 if (grp.HasPrivateAttachmentPoint && sp.ControllingClient.AgentId != grp.OwnerID) 146 if (grp.HasPrivateAttachmentPoint && sp.ControllingClient.AgentId != grp.OwnerID)
136 return; 147 return;
137
138 if (sp.ControllingClient.AgentId == grp.OwnerID)
139 dis = 0;
140 } 148 }
141 149// no radius ?
142 // Scale by distance
143 double thisSpGain = gain * ((radius - dis) / radius);
144
145 sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, 150 sp.ControllingClient.SendPlayAttachedSound(soundID, objectID,
146 ownerID, (float)thisSpGain, flags); 151 ownerID, (float)gain, flags);
147 }); 152 });
148 } 153 }
149 154
@@ -161,9 +166,9 @@ namespace OpenSim.Region.CoreModules.World.Sound
161 { 166 {
162 SceneObjectGroup grp = part.ParentGroup; 167 SceneObjectGroup grp = part.ParentGroup;
163 168
164 if (grp.IsAttachment && grp.AttachmentPoint > 30) 169 if (grp.IsAttachment && grp.HasPrivateAttachmentPoint)
165 { 170 {
166 objectID = ownerID; 171// objectID = ownerID;
167 parentID = ownerID; 172 parentID = ownerID;
168 } 173 }
169 } 174 }
@@ -174,16 +179,12 @@ namespace OpenSim.Region.CoreModules.World.Sound
174 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) 179 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
175 { 180 {
176 double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); 181 double dis = Util.GetDistanceTo(sp.AbsolutePosition, position);
177 182 if (dis > radius) // Max audio distance
178 if (dis > MaxDistance) // Max audio distance
179 return; 183 return;
180 184
181 // Scale by distance
182 double thisSpGain = gain * ((radius - dis) / radius);
183
184 sp.ControllingClient.SendTriggeredSound(soundId, ownerID, 185 sp.ControllingClient.SendTriggeredSound(soundId, ownerID,
185 objectID, parentID, handle, position, 186 objectID, parentID, handle, position,
186 (float)thisSpGain); 187 (float)gain);
187 }); 188 });
188 } 189 }
189 190
@@ -199,39 +200,12 @@ namespace OpenSim.Region.CoreModules.World.Sound
199 private static void StopSound(SceneObjectPart m_host) 200 private static void StopSound(SceneObjectPart m_host)
200 { 201 {
201 m_host.AdjustSoundGain(0); 202 m_host.AdjustSoundGain(0);
202 // Xantor 20080528: Clear prim data of sound instead 203 m_host.Sound = UUID.Zero;
203 if (m_host.ParentGroup.LoopSoundSlavePrims.Contains(m_host)) 204 m_host.SoundFlags = (byte)SoundFlags.STOP;
204 { 205 m_host.SoundRadius = 0;
205 if (m_host.ParentGroup.LoopSoundMasterPrim == m_host) 206 m_host.SoundGain = 0;
206 { 207 m_host.ScheduleFullUpdate();
207 foreach (SceneObjectPart part in m_host.ParentGroup.LoopSoundSlavePrims) 208 m_host.SendFullUpdateToAllClients();
208 {
209 part.Sound = UUID.Zero;
210 part.SoundFlags = 1 << 5;
211 part.SoundRadius = 0;
212 part.ScheduleFullUpdate();
213 part.SendFullUpdateToAllClients();
214 }
215 m_host.ParentGroup.LoopSoundMasterPrim = null;
216 m_host.ParentGroup.LoopSoundSlavePrims.Clear();
217 }
218 else
219 {
220 m_host.Sound = UUID.Zero;
221 m_host.SoundFlags = 1 << 5;
222 m_host.SoundRadius = 0;
223 m_host.ScheduleFullUpdate();
224 m_host.SendFullUpdateToAllClients();
225 }
226 }
227 else
228 {
229 m_host.Sound = UUID.Zero;
230 m_host.SoundFlags = 1 << 5;
231 m_host.SoundRadius = 0;
232 m_host.ScheduleFullUpdate();
233 m_host.SendFullUpdateToAllClients();
234 }
235 } 209 }
236 210
237 public virtual void PreloadSound(UUID objectID, UUID soundID, float radius) 211 public virtual void PreloadSound(UUID objectID, UUID soundID, float radius)
@@ -248,7 +222,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
248 222
249 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) 223 m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
250 { 224 {
251 if (!(Util.GetDistanceTo(sp.AbsolutePosition, part.AbsolutePosition) >= MaxDistance)) 225 if (Util.GetDistanceTo(sp.AbsolutePosition, part.AbsolutePosition) < radius)
252 sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); 226 sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
253 }); 227 });
254 } 228 }
@@ -262,21 +236,31 @@ namespace OpenSim.Region.CoreModules.World.Sound
262 // 20080530 Updated to remove code duplication 236 // 20080530 Updated to remove code duplication
263 // 20080530 Stop sound if there is one, otherwise volume only changes don't work 237 // 20080530 Stop sound if there is one, otherwise volume only changes don't work
264 public void LoopSound(UUID objectID, UUID soundID, 238 public void LoopSound(UUID objectID, UUID soundID,
265 double volume, double radius, bool isMaster) 239 double volume, double radius, bool isMaster, bool isSlave)
266 { 240 {
267 SceneObjectPart m_host; 241 SceneObjectPart m_host;
268 if (!m_scene.TryGetSceneObjectPart(objectID, out m_host)) 242 if (!m_scene.TryGetSceneObjectPart(objectID, out m_host))
269 return; 243 return;
270 244
271 if (isMaster) 245// if (isMaster)
272 m_host.ParentGroup.LoopSoundMasterPrim = m_host; 246// m_host.ParentGroup.LoopSoundMasterPrim = m_host;
273 247
274 if (m_host.Sound != UUID.Zero) 248 // sl does not stop previus sound, volume changes don't work (wiki)
275 StopSound(m_host); 249// if (m_host.Sound != UUID.Zero)
250// StopSound(m_host);
251
252 byte iflags = 1; // looping
253 if (isMaster)
254 iflags |= (byte)SoundFlags.SYNC_MASTER;
255 // TODO check viewer seems to accept both
256 if (isSlave)
257 iflags |= (byte)SoundFlags.SYNC_SLAVE;
258 if (m_host.SoundQueueing)
259 iflags |= (byte)SoundFlags.QUEUE;
276 260
277 m_host.Sound = soundID; 261 m_host.Sound = soundID;
278 m_host.SoundGain = volume; 262 m_host.SoundGain = volume;
279 m_host.SoundFlags = 1; // looping 263 m_host.SoundFlags = iflags;
280 m_host.SoundRadius = radius; 264 m_host.SoundRadius = radius;
281 265
282 m_host.ScheduleFullUpdate(); 266 m_host.ScheduleFullUpdate();
@@ -301,42 +285,19 @@ namespace OpenSim.Region.CoreModules.World.Sound
301 Vector3 position = part.AbsolutePosition; // region local 285 Vector3 position = part.AbsolutePosition; // region local
302 ulong regionHandle = m_scene.RegionInfo.RegionHandle; 286 ulong regionHandle = m_scene.RegionInfo.RegionHandle;
303 287
304 if (useMaster) 288 if(triggered)
305 { 289 TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius);
306 if (isMaster)
307 {
308 if (triggered)
309 TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius);
310 else
311 PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius);
312 part.ParentGroup.PlaySoundMasterPrim = part;
313 if (triggered)
314 TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius);
315 else
316 PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius);
317 foreach (SceneObjectPart prim in part.ParentGroup.PlaySoundSlavePrims)
318 {
319 position = prim.AbsolutePosition; // region local
320 if (triggered)
321 TriggerSound(soundID, part.OwnerID, prim.UUID, parentID, volume, position, regionHandle, radius);
322 else
323 PlayAttachedSound(soundID, part.OwnerID, prim.UUID, volume, position, flags, radius);
324 }
325 part.ParentGroup.PlaySoundSlavePrims.Clear();
326 part.ParentGroup.PlaySoundMasterPrim = null;
327 }
328 else
329 {
330 part.ParentGroup.PlaySoundSlavePrims.Add(part);
331 }
332 }
333 else 290 else
334 { 291 {
335 if (triggered) 292 byte bflags = 0;
336 TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius); 293
337 else 294 if (isMaster)
338 PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius); 295 bflags |= (byte)SoundFlags.SYNC_MASTER;
339 } 296 // TODO check viewer seems to accept both
297 if (useMaster)
298 bflags |= (byte)SoundFlags.SYNC_SLAVE;
299 PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, bflags, radius);
300 }
340 } 301 }
341 302
342 public void TriggerSoundLimited(UUID objectID, UUID sound, 303 public void TriggerSoundLimited(UUID objectID, UUID sound,
diff --git a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs
index 8372ddd..f7c6513 100644
--- a/OpenSim/Region/Framework/Interfaces/ISoundModule.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISoundModule.cs
@@ -95,7 +95,7 @@ namespace OpenSim.Region.Framework.Interfaces
95 /// <param name="radius">Sound radius</param> 95 /// <param name="radius">Sound radius</param>
96 /// <param name="isMaster">Set object to sync master if true</param> 96 /// <param name="isMaster">Set object to sync master if true</param>
97 void LoopSound(UUID objectID, UUID soundID, double gain, 97 void LoopSound(UUID objectID, UUID soundID, double gain,
98 double radius, bool isMaster); 98 double radius, bool isMaster, bool isSlave);
99 99
100 /// <summary> 100 /// <summary>
101 /// Trigger or play an attached sound in this part's inventory. 101 /// Trigger or play an attached sound in this part's inventory.
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 9527fa5..ba97c47 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -908,14 +908,14 @@ namespace OpenSim.Region.Framework.Scenes
908 } 908 }
909 } 909 }
910 } 910 }
911 911 // PlaySoundMasterPrim no longer in use to remove
912 private SceneObjectPart m_PlaySoundMasterPrim = null; 912 private SceneObjectPart m_PlaySoundMasterPrim = null;
913 public SceneObjectPart PlaySoundMasterPrim 913 public SceneObjectPart PlaySoundMasterPrim
914 { 914 {
915 get { return m_PlaySoundMasterPrim; } 915 get { return m_PlaySoundMasterPrim; }
916 set { m_PlaySoundMasterPrim = value; } 916 set { m_PlaySoundMasterPrim = value; }
917 } 917 }
918 918 // PlaySoundSlavePrims no longer in use to remove
919 private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>(); 919 private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>();
920 public List<SceneObjectPart> PlaySoundSlavePrims 920 public List<SceneObjectPart> PlaySoundSlavePrims
921 { 921 {
@@ -923,6 +923,7 @@ namespace OpenSim.Region.Framework.Scenes
923 set { m_PlaySoundSlavePrims = value; } 923 set { m_PlaySoundSlavePrims = value; }
924 } 924 }
925 925
926 // LoopSoundMasterPrim no longer in use to remove
926 private SceneObjectPart m_LoopSoundMasterPrim = null; 927 private SceneObjectPart m_LoopSoundMasterPrim = null;
927 public SceneObjectPart LoopSoundMasterPrim 928 public SceneObjectPart LoopSoundMasterPrim
928 { 929 {
@@ -930,6 +931,7 @@ namespace OpenSim.Region.Framework.Scenes
930 set { m_LoopSoundMasterPrim = value; } 931 set { m_LoopSoundMasterPrim = value; }
931 } 932 }
932 933
934 // m_LoopSoundSlavePrims no longer in use to remove
933 private List<SceneObjectPart> m_LoopSoundSlavePrims = new List<SceneObjectPart>(); 935 private List<SceneObjectPart> m_LoopSoundSlavePrims = new List<SceneObjectPart>();
934 public List<SceneObjectPart> LoopSoundSlavePrims 936 public List<SceneObjectPart> LoopSoundSlavePrims
935 { 937 {
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 4cb65d4..c65f933 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -2844,7 +2844,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2844 m_SoundModule.SendSound( 2844 m_SoundModule.SendSound(
2845 m_host.UUID, 2845 m_host.UUID,
2846 ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound), 2846 ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound),
2847 volume, false, m_host.SoundQueueing ? (byte)SoundFlags.Queue : (byte)SoundFlags.None, 2847 volume, false, 0,
2848 0, false, false); 2848 0, false, false);
2849 } 2849 }
2850 } 2850 }
@@ -2855,7 +2855,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2855 if (m_SoundModule != null) 2855 if (m_SoundModule != null)
2856 { 2856 {
2857 m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), 2857 m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound),
2858 volume, 20, false); 2858 volume, 20, false,false);
2859 } 2859 }
2860 } 2860 }
2861 2861
@@ -2865,16 +2865,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
2865 if (m_SoundModule != null) 2865 if (m_SoundModule != null)
2866 { 2866 {
2867 m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound), 2867 m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound),
2868 volume, 20, true); 2868 volume, 20, true, false);
2869 } 2869 }
2870 } 2870 }
2871 2871
2872 public void llLoopSoundSlave(string sound, double volume) 2872 public void llLoopSoundSlave(string sound, double volume)
2873 { 2873 {
2874 m_host.AddScriptLPS(1); 2874 m_host.AddScriptLPS(1);
2875 lock (m_host.ParentGroup.LoopSoundSlavePrims) 2875 if (m_SoundModule != null)
2876 { 2876 {
2877 m_host.ParentGroup.LoopSoundSlavePrims.Add(m_host); 2877 m_SoundModule.LoopSound(m_host.UUID, ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound),
2878 volume, 20, false, true);
2878 } 2879 }
2879 } 2880 }
2880 2881