diff options
author | onefang | 2019-09-11 16:36:50 +1000 |
---|---|---|
committer | onefang | 2019-09-11 16:36:50 +1000 |
commit | 50cd1ffd32f69228e566f2b0b89f86ea0d9fe489 (patch) | |
tree | 52f2ab0c04f1a5d7d6ac5dc872981b4b156447e7 /OpenSim/Region/CoreModules/World/Sound/SoundModule.cs | |
parent | Renamed branch to SledjChisl. (diff) | |
parent | Bump to release flavour, build 0. (diff) | |
download | opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.zip opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.gz opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.bz2 opensim-SC_OLD-50cd1ffd32f69228e566f2b0b89f86ea0d9fe489.tar.xz |
Merge branch 'SledjChisl'
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Sound/SoundModule.cs | 174 |
1 files changed, 77 insertions, 97 deletions
diff --git a/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs b/OpenSim/Region/CoreModules/World/Sound/SoundModule.cs index d093224..2b7db18 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,30 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
124 | if (radius == 0) | 136 | if (radius == 0) |
125 | radius = MaxDistance; | 137 | radius = MaxDistance; |
126 | 138 | ||
127 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) | 139 | if (part.SoundQueueing) |
140 | flags |= (byte)SoundFlags.QUEUE; | ||
141 | |||
142 | if (grp.IsAttachment) | ||
128 | { | 143 | { |
129 | double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); | 144 | ScenePresence ssp = null; |
130 | if (dis > MaxDistance) // Max audio distance | 145 | if (!m_scene.TryGetScenePresence(grp.AttachedAvatar, out ssp)) |
131 | return; | 146 | return; |
132 | 147 | ||
133 | if (grp.IsAttachment) | 148 | if (grp.HasPrivateAttachmentPoint) |
134 | { | 149 | { |
135 | if (grp.HasPrivateAttachmentPoint && sp.ControllingClient.AgentId != grp.OwnerID) | 150 | ssp.ControllingClient.SendPlayAttachedSound(soundID, objectID, |
136 | return; | 151 | ownerID, (float)gain, flags); |
137 | 152 | return; | |
138 | if (sp.ControllingClient.AgentId == grp.OwnerID) | ||
139 | dis = 0; | ||
140 | } | 153 | } |
141 | 154 | ||
142 | // Scale by distance | 155 | if (!ssp.ParcelAllowThisAvatarSounds) |
143 | double thisSpGain = gain * ((radius - dis) / radius); | 156 | return; |
157 | } | ||
144 | 158 | ||
159 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) | ||
160 | { | ||
145 | sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, | 161 | sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, |
146 | ownerID, (float)thisSpGain, flags); | 162 | ownerID, (float)gain, flags); |
147 | }); | 163 | }); |
148 | } | 164 | } |
149 | 165 | ||
@@ -151,20 +167,35 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
151 | UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius) | 167 | UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius) |
152 | { | 168 | { |
153 | SceneObjectPart part; | 169 | SceneObjectPart part; |
170 | ScenePresence ssp = null; | ||
154 | if (!m_scene.TryGetSceneObjectPart(objectID, out part)) | 171 | if (!m_scene.TryGetSceneObjectPart(objectID, out part)) |
155 | { | 172 | { |
156 | ScenePresence sp; | 173 | if (!m_scene.TryGetScenePresence(ownerID, out ssp)) |
157 | if (!m_scene.TryGetScenePresence(ownerID, out sp)) | 174 | return; |
175 | if (!ssp.ParcelAllowThisAvatarSounds) | ||
158 | return; | 176 | return; |
159 | } | 177 | } |
160 | else | 178 | else |
161 | { | 179 | { |
162 | SceneObjectGroup grp = part.ParentGroup; | 180 | SceneObjectGroup grp = part.ParentGroup; |
163 | 181 | ||
164 | if (grp.IsAttachment && grp.AttachmentPoint > 30) | 182 | if (grp.IsAttachment) |
165 | { | 183 | { |
166 | objectID = ownerID; | 184 | if (!m_scene.TryGetScenePresence(grp.AttachedAvatar, out ssp)) |
167 | parentID = ownerID; | 185 | return; |
186 | |||
187 | if (!ssp.ParcelAllowThisAvatarSounds) | ||
188 | return; | ||
189 | |||
190 | /* mantis 7942: coment out to allow trigger in HUDs to send sounds to all | ||
191 | if (grp.HasPrivateAttachmentPoint) | ||
192 | { | ||
193 | ssp.ControllingClient.SendTriggeredSound(soundId, ownerID, | ||
194 | objectID, parentID, handle, position, | ||
195 | (float)gain); | ||
196 | return; | ||
197 | } | ||
198 | */ | ||
168 | } | 199 | } |
169 | } | 200 | } |
170 | 201 | ||
@@ -174,16 +205,12 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
174 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) | 205 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) |
175 | { | 206 | { |
176 | double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); | 207 | double dis = Util.GetDistanceTo(sp.AbsolutePosition, position); |
177 | 208 | if (dis > radius) // Max audio distance | |
178 | if (dis > MaxDistance) // Max audio distance | ||
179 | return; | 209 | return; |
180 | 210 | ||
181 | // Scale by distance | ||
182 | double thisSpGain = gain * ((radius - dis) / radius); | ||
183 | |||
184 | sp.ControllingClient.SendTriggeredSound(soundId, ownerID, | 211 | sp.ControllingClient.SendTriggeredSound(soundId, ownerID, |
185 | objectID, parentID, handle, position, | 212 | objectID, parentID, handle, position, |
186 | (float)thisSpGain); | 213 | (float)gain); |
187 | }); | 214 | }); |
188 | } | 215 | } |
189 | 216 | ||
@@ -198,40 +225,13 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
198 | 225 | ||
199 | private static void StopSound(SceneObjectPart m_host) | 226 | private static void StopSound(SceneObjectPart m_host) |
200 | { | 227 | { |
201 | m_host.AdjustSoundGain(0); | 228 | // m_host.AdjustSoundGain(0); |
202 | // Xantor 20080528: Clear prim data of sound instead | 229 | m_host.Sound = UUID.Zero; |
203 | if (m_host.ParentGroup.LoopSoundSlavePrims.Contains(m_host)) | 230 | m_host.SoundFlags = (byte)SoundFlags.STOP; |
204 | { | 231 | m_host.SoundRadius = 0; |
205 | if (m_host.ParentGroup.LoopSoundMasterPrim == m_host) | 232 | m_host.SoundGain = 0; |
206 | { | 233 | m_host.ScheduleFullUpdate(); |
207 | foreach (SceneObjectPart part in m_host.ParentGroup.LoopSoundSlavePrims) | 234 | 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 | } | 235 | } |
236 | 236 | ||
237 | public virtual void PreloadSound(UUID objectID, UUID soundID, float radius) | 237 | public virtual void PreloadSound(UUID objectID, UUID soundID, float radius) |
@@ -248,7 +248,7 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
248 | 248 | ||
249 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) | 249 | m_scene.ForEachRootScenePresence(delegate(ScenePresence sp) |
250 | { | 250 | { |
251 | if (!(Util.GetDistanceTo(sp.AbsolutePosition, part.AbsolutePosition) >= MaxDistance)) | 251 | if (Util.GetDistanceTo(sp.AbsolutePosition, part.AbsolutePosition) < radius) |
252 | sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); | 252 | sp.ControllingClient.SendPreLoadSound(objectID, objectID, soundID); |
253 | }); | 253 | }); |
254 | } | 254 | } |
@@ -262,21 +262,24 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
262 | // 20080530 Updated to remove code duplication | 262 | // 20080530 Updated to remove code duplication |
263 | // 20080530 Stop sound if there is one, otherwise volume only changes don't work | 263 | // 20080530 Stop sound if there is one, otherwise volume only changes don't work |
264 | public void LoopSound(UUID objectID, UUID soundID, | 264 | public void LoopSound(UUID objectID, UUID soundID, |
265 | double volume, double radius, bool isMaster) | 265 | double volume, double radius, bool isMaster, bool isSlave) |
266 | { | 266 | { |
267 | SceneObjectPart m_host; | 267 | SceneObjectPart m_host; |
268 | if (!m_scene.TryGetSceneObjectPart(objectID, out m_host)) | 268 | if (!m_scene.TryGetSceneObjectPart(objectID, out m_host)) |
269 | return; | 269 | return; |
270 | 270 | ||
271 | byte iflags = 1; // looping | ||
271 | if (isMaster) | 272 | if (isMaster) |
272 | m_host.ParentGroup.LoopSoundMasterPrim = m_host; | 273 | iflags |= (byte)SoundFlags.SYNC_MASTER; |
273 | 274 | // TODO check viewer seems to accept both | |
274 | if (m_host.Sound != UUID.Zero) | 275 | if (isSlave) |
275 | StopSound(m_host); | 276 | iflags |= (byte)SoundFlags.SYNC_SLAVE; |
277 | if (m_host.SoundQueueing) | ||
278 | iflags |= (byte)SoundFlags.QUEUE; | ||
276 | 279 | ||
277 | m_host.Sound = soundID; | 280 | m_host.Sound = soundID; |
278 | m_host.SoundGain = volume; | 281 | m_host.SoundGain = volume; |
279 | m_host.SoundFlags = 1; // looping | 282 | m_host.SoundFlags = iflags; |
280 | m_host.SoundRadius = radius; | 283 | m_host.SoundRadius = radius; |
281 | 284 | ||
282 | m_host.ScheduleFullUpdate(); | 285 | m_host.ScheduleFullUpdate(); |
@@ -301,41 +304,18 @@ namespace OpenSim.Region.CoreModules.World.Sound | |||
301 | Vector3 position = part.AbsolutePosition; // region local | 304 | Vector3 position = part.AbsolutePosition; // region local |
302 | ulong regionHandle = m_scene.RegionInfo.RegionHandle; | 305 | ulong regionHandle = m_scene.RegionInfo.RegionHandle; |
303 | 306 | ||
304 | if (useMaster) | 307 | if(triggered) |
305 | { | 308 | 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 | 309 | else |
334 | { | 310 | { |
335 | if (triggered) | 311 | byte bflags = 0; |
336 | TriggerSound(soundID, part.OwnerID, part.UUID, parentID, volume, position, regionHandle, radius); | 312 | |
337 | else | 313 | if (isMaster) |
338 | PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, flags, radius); | 314 | bflags |= (byte)SoundFlags.SYNC_MASTER; |
315 | // TODO check viewer seems to accept both | ||
316 | if (useMaster) | ||
317 | bflags |= (byte)SoundFlags.SYNC_SLAVE; | ||
318 | PlayAttachedSound(soundID, part.OwnerID, part.UUID, volume, position, bflags, radius); | ||
339 | } | 319 | } |
340 | } | 320 | } |
341 | 321 | ||