mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 00:46:02 +08:00
make llLinkPlaySound() closer to spec
This commit is contained in:
@@ -26,7 +26,6 @@
|
||||
*/
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
using Nini.Config;
|
||||
@@ -43,8 +42,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SoundModule")]
|
||||
public class SoundModule : INonSharedRegionModule, ISoundModule
|
||||
{
|
||||
// private static readonly ILog m_log = LogManager.GetLogger(
|
||||
// MethodBase.GetCurrentMethod().DeclaringType);
|
||||
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private Scene m_scene;
|
||||
|
||||
@@ -52,11 +50,11 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||
{
|
||||
NONE = 0,
|
||||
LOOP = 1 << 0,
|
||||
SYNC_MASTER = 1<<1,
|
||||
SYNC_SLAVE = 1<<2,
|
||||
SYNC_PENDING = 1<<3,
|
||||
QUEUE = 1<<4,
|
||||
STOP = 1<<5,
|
||||
SYNC_MASTER = 1 << 1,
|
||||
SYNC_SLAVE = 1 << 2,
|
||||
SYNC_PENDING = 1 << 3,
|
||||
QUEUE = 1 << 4,
|
||||
STOP = 1 << 5,
|
||||
SYNC_MASK = SYNC_MASTER | SYNC_SLAVE | SYNC_PENDING
|
||||
}
|
||||
|
||||
@@ -127,8 +125,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||
public virtual void PlayAttachedSound(
|
||||
UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags)
|
||||
{
|
||||
SceneObjectPart part;
|
||||
if (!m_scene.TryGetSceneObjectPart(objectID, out part))
|
||||
if (!m_scene.TryGetSceneObjectPart(objectID, out SceneObjectPart part))
|
||||
return;
|
||||
|
||||
if (part.SoundRadius == 0)
|
||||
@@ -170,9 +167,8 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||
UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle)
|
||||
{
|
||||
float radius;
|
||||
SceneObjectPart part;
|
||||
ScenePresence ssp = null;
|
||||
if (!m_scene.TryGetSceneObjectPart(objectID, out part))
|
||||
if (!m_scene.TryGetSceneObjectPart(objectID, out SceneObjectPart part))
|
||||
{
|
||||
if (!m_scene.TryGetScenePresence(ownerID, out ssp))
|
||||
return;
|
||||
@@ -219,9 +215,8 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||
UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle)
|
||||
{
|
||||
float radius;
|
||||
SceneObjectPart part;
|
||||
ScenePresence ssp = null;
|
||||
if (!m_scene.TryGetSceneObjectPart(objectID, out part))
|
||||
if (!m_scene.TryGetSceneObjectPart(objectID, out SceneObjectPart part))
|
||||
{
|
||||
if (!m_scene.TryGetScenePresence(ownerID, out ssp))
|
||||
return;
|
||||
@@ -269,11 +264,8 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||
|
||||
public virtual void StopSound(UUID objectID)
|
||||
{
|
||||
SceneObjectPart m_host;
|
||||
if (!m_scene.TryGetSceneObjectPart(objectID, out m_host))
|
||||
return;
|
||||
|
||||
StopSound(m_host);
|
||||
if (m_scene.TryGetSceneObjectPart(objectID, out SceneObjectPart m_host))
|
||||
StopSound(m_host);
|
||||
}
|
||||
|
||||
private static void StopSound(SceneObjectPart m_host)
|
||||
@@ -287,11 +279,8 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||
|
||||
public virtual void PreloadSound(UUID objectID, UUID soundID)
|
||||
{
|
||||
SceneObjectPart part;
|
||||
if (soundID.IsZero() || !m_scene.TryGetSceneObjectPart(objectID, out part))
|
||||
{
|
||||
if (soundID.IsZero() || !m_scene.TryGetSceneObjectPart(objectID, out SceneObjectPart part))
|
||||
return;
|
||||
}
|
||||
|
||||
float radius = (float)part.SoundRadius;
|
||||
if (radius == 0)
|
||||
@@ -319,8 +308,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||
public void LoopSound(UUID objectID, UUID soundID,
|
||||
double volume, bool isMaster, bool isSlave)
|
||||
{
|
||||
SceneObjectPart m_host;
|
||||
if (!m_scene.TryGetSceneObjectPart(objectID, out m_host))
|
||||
if (!m_scene.TryGetSceneObjectPart(objectID, out SceneObjectPart m_host))
|
||||
return;
|
||||
|
||||
byte iflags = 1; // looping
|
||||
@@ -349,8 +337,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||
if (soundID.IsZero())
|
||||
return;
|
||||
|
||||
SceneObjectPart part;
|
||||
if (!m_scene.TryGetSceneObjectPart(objectID, out part))
|
||||
if (!m_scene.TryGetSceneObjectPart(objectID, out SceneObjectPart part))
|
||||
return;
|
||||
|
||||
volume = Utils.Clamp(volume, 0, 1);
|
||||
@@ -381,14 +368,12 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||
if (sound.IsZero())
|
||||
return;
|
||||
|
||||
SceneObjectPart part;
|
||||
if (!m_scene.TryGetSceneObjectPart(objectID, out part))
|
||||
if (!m_scene.TryGetSceneObjectPart(objectID, out SceneObjectPart part))
|
||||
return;
|
||||
|
||||
m_scene.ForEachRootScenePresence(delegate(ScenePresence sp)
|
||||
{
|
||||
double dis = Util.GetDistanceTo(sp.AbsolutePosition,
|
||||
part.AbsolutePosition);
|
||||
double dis = Util.GetDistanceTo(sp.AbsolutePosition, part.AbsolutePosition);
|
||||
|
||||
if (dis > MaxDistance) // Max audio distance
|
||||
return;
|
||||
@@ -408,11 +393,8 @@ 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;
|
||||
if (m_scene.TryGetSceneObjectPart(objectID, out SceneObjectPart part))
|
||||
part.SoundQueueing = shouldQueue;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -70,6 +70,7 @@ using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
|
||||
using PrimType = OpenSim.Region.Framework.Scenes.PrimType;
|
||||
using RegionFlags = OpenSim.Framework.RegionFlags;
|
||||
using RegionInfo = OpenSim.Framework.RegionInfo;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
#pragma warning disable IDE1006
|
||||
|
||||
@@ -2906,32 +2907,50 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
m_SoundModule.SendSound(m_host.UUID, soundID, volume, false, 0, false, false);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void llLinkPlaySound(LSL_Integer linknumber, string sound, double volume)
|
||||
{
|
||||
llLinkPlaySound(linknumber, sound, volume, 0);
|
||||
}
|
||||
|
||||
public void llLinkPlaySound(LSL_Integer linknumber, string sound, double volume, LSL_Integer flags)
|
||||
{
|
||||
if (m_SoundModule is null)
|
||||
return;
|
||||
if (m_host.ParentGroup is null || m_host.ParentGroup.IsDeleted)
|
||||
return;
|
||||
|
||||
SceneObjectPart sop;
|
||||
if (linknumber == ScriptBaseClass.LINK_THIS)
|
||||
sop = m_host;
|
||||
else if (linknumber < 0)
|
||||
return;
|
||||
else if (linknumber < 2)
|
||||
sop = m_host.ParentGroup.RootPart;
|
||||
else
|
||||
sop = m_host.ParentGroup.GetLinkNumPart(linknumber);
|
||||
|
||||
if(sop == null)
|
||||
return;
|
||||
|
||||
UUID soundID = ScriptUtils.GetAssetIdFromKeyOrItemName(m_host, sound, AssetType.Sound);
|
||||
if (soundID.IsZero())
|
||||
return;
|
||||
|
||||
// send the sound, once, to all clients in range
|
||||
m_SoundModule.SendSound(sop.UUID, soundID, volume, false, 0, false, false);
|
||||
List<SceneObjectPart> parts = GetLinkParts(m_host, linknumber.value);
|
||||
if (parts.Count == 0)
|
||||
return;
|
||||
|
||||
switch (flags)
|
||||
{
|
||||
case 0: // play
|
||||
foreach (SceneObjectPart sop in parts)
|
||||
m_SoundModule.SendSound(sop.UUID, soundID, volume, false, 0, false, false);
|
||||
break;
|
||||
case 1: // loop
|
||||
foreach (SceneObjectPart sop in parts)
|
||||
m_SoundModule.LoopSound(sop.UUID, soundID, volume, false, false);
|
||||
break;
|
||||
case 2: //trigger
|
||||
foreach (SceneObjectPart sop in parts)
|
||||
m_SoundModule.SendSound(sop.UUID, soundID, volume, true, 0, false, false);
|
||||
break;
|
||||
case 4: // play slave
|
||||
foreach (SceneObjectPart sop in parts)
|
||||
m_SoundModule.SendSound(sop.UUID, soundID, volume, false, 0, true, false);
|
||||
break;
|
||||
case 5: // loop slave
|
||||
foreach (SceneObjectPart sop in parts)
|
||||
m_SoundModule.LoopSound(sop.UUID, soundID, volume, false, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void llLoopSound(string sound, double volume)
|
||||
@@ -6026,7 +6045,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||
|
||||
}
|
||||
|
||||
private bool ListFind_areEqual(object l, object r)
|
||||
private static bool ListFind_areEqual(object l, object r)
|
||||
{
|
||||
if (l is null || r is null)
|
||||
return false;
|
||||
|
||||
@@ -493,8 +493,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
||||
|
||||
void llLinkAdjustSoundVolume(LSL_Integer linknumber, LSL_Float volume);
|
||||
void llLinkStopSound(LSL_Integer linknumber);
|
||||
void llLinkPlaySound(LSL_Integer linknumber, string sound, double volume);
|
||||
void llLinkSetSoundQueueing(int linknumber, int queue);
|
||||
void llLinkPlaySound(LSL_Integer linknumber, string sound, double volume);
|
||||
void llLinkPlaySound(LSL_Integer linknumber, string sound, double volume, LSL_Integer flags);
|
||||
void llLinkSetSoundRadius(int linknumber, double radius);
|
||||
|
||||
LSL_Vector llLinear2sRGB(LSL_Vector src);
|
||||
|
||||
@@ -2677,6 +2677,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
||||
m_LSL_Functions.llLinkPlaySound(linknumber, sound, volume);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void llLinkPlaySound(LSL_Integer linknumber, string sound, double volume, LSL_Integer flags)
|
||||
{
|
||||
m_LSL_Functions.llLinkPlaySound(linknumber, sound, volume, flags);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public void llLinkSetSoundQueueing(int linknumber, int queue)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user