deduplicating code into a single LoopSound method
parent
22693304fb
commit
9df510157e
|
@ -248,13 +248,22 @@ namespace OpenSim.Region.CoreModules.World.Sound
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void LoopSoundMaster(UUID objectID, UUID soundID,
|
// Xantor 20080528 we should do this differently.
|
||||||
double volume, double radius)
|
// 1) apply the sound to the object
|
||||||
|
// 2) schedule full update
|
||||||
|
// just sending the sound out once doesn't work so well when other avatars come in view later on
|
||||||
|
// or when the prim gets moved, changed, sat on, whatever
|
||||||
|
// see large number of mantises (mantes?)
|
||||||
|
// 20080530 Updated to remove code duplication
|
||||||
|
// 20080530 Stop sound if there is one, otherwise volume only changes don't work
|
||||||
|
public void LoopSound(UUID objectID, UUID soundID,
|
||||||
|
double volume, double radius, bool isMaster)
|
||||||
{
|
{
|
||||||
SceneObjectPart m_host;
|
SceneObjectPart m_host;
|
||||||
if (!m_scene.TryGetSceneObjectPart(objectID, out m_host))
|
if (!m_scene.TryGetSceneObjectPart(objectID, out m_host))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (isMaster)
|
||||||
m_host.ParentGroup.LoopSoundMasterPrim = m_host;
|
m_host.ParentGroup.LoopSoundMasterPrim = m_host;
|
||||||
|
|
||||||
if (m_host.Sound != UUID.Zero)
|
if (m_host.Sound != UUID.Zero)
|
||||||
|
|
|
@ -86,14 +86,15 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
void PreloadSound(UUID objectID, UUID soundID, float radius);
|
void PreloadSound(UUID objectID, UUID soundID, float radius);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Declare object as new sync master, play specified sound at
|
/// Loop specified sound at specified volume with specified radius,
|
||||||
/// specified volume with specified radius.
|
/// optionally declaring object as new sync master.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="objectID">Sound source ID</param>
|
/// <param name="objectID">Sound source ID</param>
|
||||||
/// <param name="soundID">Sound asset ID</param>
|
/// <param name="soundID">Sound asset ID</param>
|
||||||
/// <param name="gain">Sound volume</param>
|
/// <param name="gain">Sound volume</param>
|
||||||
/// <param name="radius">Sound radius</param>
|
/// <param name="radius">Sound radius</param>
|
||||||
void LoopSoundMaster(UUID objectID, UUID soundID, double gain,
|
/// <param name="isMaster">Set object to sync master if true</param>
|
||||||
double radius);
|
void LoopSound(UUID objectID, UUID soundID, double gain,
|
||||||
|
double radius, bool isMaster);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2370,28 +2370,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0, 0, false, false);
|
m_host.SendSound(KeyOrName(sound).ToString(), volume, false, 0, 0, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Xantor 20080528 we should do this differently.
|
|
||||||
// 1) apply the sound to the object
|
|
||||||
// 2) schedule full update
|
|
||||||
// just sending the sound out once doesn't work so well when other avatars come in view later on
|
|
||||||
// or when the prim gets moved, changed, sat on, whatever
|
|
||||||
// see large number of mantises (mantes?)
|
|
||||||
// 20080530 Updated to remove code duplication
|
|
||||||
// 20080530 Stop sound if there is one, otherwise volume only changes don't work
|
|
||||||
public void llLoopSound(string sound, double volume)
|
public void llLoopSound(string sound, double volume)
|
||||||
{
|
{
|
||||||
m_host.AddScriptLPS(1);
|
m_host.AddScriptLPS(1);
|
||||||
|
if (m_SoundModule != null)
|
||||||
if (m_host.Sound != UUID.Zero)
|
{
|
||||||
llStopSound();
|
m_SoundModule.LoopSound(m_host.UUID, KeyOrName(sound),
|
||||||
|
volume, 20, false);
|
||||||
m_host.Sound = KeyOrName(sound);
|
}
|
||||||
m_host.SoundGain = volume;
|
|
||||||
m_host.SoundFlags = 1; // looping
|
|
||||||
m_host.SoundRadius = 20; // Magic number, 20 seems reasonable. Make configurable?
|
|
||||||
|
|
||||||
m_host.ScheduleFullUpdate();
|
|
||||||
m_host.SendFullUpdateToAllClients();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void llLoopSoundMaster(string sound, double volume)
|
public void llLoopSoundMaster(string sound, double volume)
|
||||||
|
@ -2399,8 +2385,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
m_host.AddScriptLPS(1);
|
m_host.AddScriptLPS(1);
|
||||||
if (m_SoundModule != null)
|
if (m_SoundModule != null)
|
||||||
{
|
{
|
||||||
m_SoundModule.LoopSoundMaster(m_host.UUID, KeyOrName(sound),
|
m_SoundModule.LoopSound(m_host.UUID, KeyOrName(sound),
|
||||||
volume, 20);
|
volume, 20, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue