public BufferSound(UUID soundId)\r
: base()\r
{\r
- lock (allBuffers)\r
- allBuffers[soundId] = this;\r
-\r
prefetchOnly = true;\r
ContainerId = UUID.Zero;\r
Id = soundId;\r
// If this was a Prefetch, just stop here.\r
if (prefetchOnly)\r
{\r
- lock (allBuffers)\r
- allBuffers.Remove(Id);\r
return;\r
}\r
\r
// Release the buffer to avoid a big memory leak.\r
if (channel != null)\r
{\r
+ lock(allChannels)\r
+ allChannels.Remove(channel.getRaw());\r
chanStr = channel.getRaw().ToString("X");\r
channel.stop();\r
channel = null;\r
}\r
+\r
if (sound != null)\r
{\r
soundStr = sound.getRaw().ToString("X");\r
/// <param name="e"></param>
private void Sound_AttachedSound(object sender, AttachedSoundEventArgs e)
{
- // We seem to get a lot of these zero sounds.
- if (e.SoundID == UUID.Zero) return;
+ // This event tells us the Object ID, but not the Prim info directly.
+ // So we look it up in our internal Object memory.
+ Simulator sim = e.Simulator;
+ Primitive p = sim.ObjectsPrimitives.Find((Primitive p2) => { return p2.ID == e.ObjectID; });
+ if (p == null) return;
+
+ // Only one attached sound per prim, so we kill any previous
+ BufferSound.Kill(p.ID);
+ // If this is stop sound, we're done since we've already killed sound for this object
if ((e.Flags & SoundFlags.Stop) == SoundFlags.Stop)
{
- BufferSound.Kill(e.SoundID);
return;
}
- // This event tells us the Object ID, but not the Prim info directly.
- // So we look it up in our internal Object memory.
- Simulator sim = Instance.Client.Network.CurrentSim;
- Primitive p = sim.ObjectsPrimitives.Find((Primitive p2) => { return p2.ID == e.ObjectID; });
- if (p==null) return;
+ // We seem to get a lot of these zero sounds.
+ if (e.SoundID == UUID.Zero) return;
// If this is a child prim, its position is relative to the root.
Vector3 fullPosition = p.Position;
- if (p.ParentID != 0)
+
+ while (p != null && p.ParentID != 0)
{
- Primitive parentP;
- sim.ObjectsPrimitives.TryGetValue(p.ParentID, out parentP);
- if (parentP == null) return;
- fullPosition += parentP.Position;
+ Avatar av;
+ if (sim.ObjectsAvatars.TryGetValue(p.ParentID, out av))
+ {
+ p = av;
+ fullPosition += p.Position;
+ }
+ else
+ {
+ if (sim.ObjectsPrimitives.TryGetValue(p.ParentID, out p))
+ {
+ fullPosition += p.Position;
+ }
+ }
}
+ // Didn't find root prim
+ if (p == null) return;
+
new BufferSound(
e.ObjectID,
e.SoundID,
if (p.Sound == null) return;
if (p.Sound == UUID.Zero) return;
- BufferSound.Kill(p.Sound);
+ BufferSound.Kill(p.ID);
}
/// <summary>