General code cleanup in OpenAlSoundEngine.cs.
This commit is contained in:
@@ -46,9 +46,9 @@ namespace OpenRA.Platforms.Default
|
|||||||
const int GroupDistanceSqr = GroupDistance * GroupDistance;
|
const int GroupDistanceSqr = GroupDistance * GroupDistance;
|
||||||
const int PoolSize = 32;
|
const int PoolSize = 32;
|
||||||
|
|
||||||
IntPtr device;
|
readonly Dictionary<uint, PoolSlot> sourcePool = new Dictionary<uint, PoolSlot>();
|
||||||
float volume = 1f;
|
float volume = 1f;
|
||||||
Dictionary<uint, PoolSlot> sourcePool = new Dictionary<uint, PoolSlot>();
|
IntPtr device;
|
||||||
|
|
||||||
static string[] QueryDevices(string label, int type)
|
static string[] QueryDevices(string label, int type)
|
||||||
{
|
{
|
||||||
@@ -66,7 +66,7 @@ namespace OpenRA.Platforms.Default
|
|||||||
do
|
do
|
||||||
{
|
{
|
||||||
var str = Marshal.PtrToStringAuto(next);
|
var str = Marshal.PtrToStringAuto(next);
|
||||||
next += UnicodeEncoding.Default.GetByteCount(str) + 1;
|
next += Encoding.Default.GetByteCount(str) + 1;
|
||||||
devices.Add(str);
|
devices.Add(str);
|
||||||
} while (Marshal.ReadByte(next) != 0);
|
} while (Marshal.ReadByte(next) != 0);
|
||||||
|
|
||||||
@@ -255,13 +255,13 @@ namespace OpenRA.Platforms.Default
|
|||||||
|
|
||||||
public void SetSoundVolume(float volume, ISound music, ISound video)
|
public void SetSoundVolume(float volume, ISound music, ISound video)
|
||||||
{
|
{
|
||||||
var sounds = sourcePool.Select(s => s.Key).Where(b =>
|
var sounds = sourcePool.Keys.Where(key =>
|
||||||
{
|
{
|
||||||
int state;
|
int state;
|
||||||
AL10.alGetSourcei(b, AL10.AL_SOURCE_STATE, out state);
|
AL10.alGetSourcei(key, AL10.AL_SOURCE_STATE, out state);
|
||||||
return (state == AL10.AL_PLAYING || state == AL10.AL_PAUSED) &&
|
return (state == AL10.AL_PLAYING || state == AL10.AL_PAUSED) &&
|
||||||
(music == null || b != ((OpenAlSound)music).Source) &&
|
(music == null || key != ((OpenAlSound)music).Source) &&
|
||||||
(video == null || b != ((OpenAlSound)video).Source);
|
(video == null || key != ((OpenAlSound)video).Source);
|
||||||
});
|
});
|
||||||
|
|
||||||
foreach (var s in sounds)
|
foreach (var s in sounds)
|
||||||
@@ -343,8 +343,8 @@ namespace OpenRA.Platforms.Default
|
|||||||
|
|
||||||
class OpenAlSound : ISound
|
class OpenAlSound : ISound
|
||||||
{
|
{
|
||||||
public readonly uint Source = uint.MaxValue;
|
public readonly uint Source;
|
||||||
float volume = 1f;
|
float volume;
|
||||||
|
|
||||||
public OpenAlSound(uint source, uint buffer, bool looping, bool relative, WPos pos, float volume)
|
public OpenAlSound(uint source, uint buffer, bool looping, bool relative, WPos pos, float volume)
|
||||||
{
|
{
|
||||||
@@ -365,15 +365,8 @@ namespace OpenRA.Platforms.Default
|
|||||||
|
|
||||||
public float Volume
|
public float Volume
|
||||||
{
|
{
|
||||||
get
|
get { return volume; }
|
||||||
{
|
set { AL10.alSourcef(Source, AL10.AL_GAIN, volume = value); }
|
||||||
return volume;
|
|
||||||
}
|
|
||||||
|
|
||||||
set
|
|
||||||
{
|
|
||||||
AL10.alSourcef(Source, AL10.AL_GAIN, volume = value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float SeekPosition
|
public float SeekPosition
|
||||||
|
|||||||
Reference in New Issue
Block a user