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 PoolSize = 32;
|
||||
|
||||
IntPtr device;
|
||||
readonly Dictionary<uint, PoolSlot> sourcePool = new Dictionary<uint, PoolSlot>();
|
||||
float volume = 1f;
|
||||
Dictionary<uint, PoolSlot> sourcePool = new Dictionary<uint, PoolSlot>();
|
||||
IntPtr device;
|
||||
|
||||
static string[] QueryDevices(string label, int type)
|
||||
{
|
||||
@@ -66,7 +66,7 @@ namespace OpenRA.Platforms.Default
|
||||
do
|
||||
{
|
||||
var str = Marshal.PtrToStringAuto(next);
|
||||
next += UnicodeEncoding.Default.GetByteCount(str) + 1;
|
||||
next += Encoding.Default.GetByteCount(str) + 1;
|
||||
devices.Add(str);
|
||||
} while (Marshal.ReadByte(next) != 0);
|
||||
|
||||
@@ -255,13 +255,13 @@ namespace OpenRA.Platforms.Default
|
||||
|
||||
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;
|
||||
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) &&
|
||||
(music == null || b != ((OpenAlSound)music).Source) &&
|
||||
(video == null || b != ((OpenAlSound)video).Source);
|
||||
(music == null || key != ((OpenAlSound)music).Source) &&
|
||||
(video == null || key != ((OpenAlSound)video).Source);
|
||||
});
|
||||
|
||||
foreach (var s in sounds)
|
||||
@@ -343,8 +343,8 @@ namespace OpenRA.Platforms.Default
|
||||
|
||||
class OpenAlSound : ISound
|
||||
{
|
||||
public readonly uint Source = uint.MaxValue;
|
||||
float volume = 1f;
|
||||
public readonly uint Source;
|
||||
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
|
||||
{
|
||||
get
|
||||
{
|
||||
return volume;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
AL10.alSourcef(Source, AL10.AL_GAIN, volume = value);
|
||||
}
|
||||
get { return volume; }
|
||||
set { AL10.alSourcef(Source, AL10.AL_GAIN, volume = value); }
|
||||
}
|
||||
|
||||
public float SeekPosition
|
||||
|
||||
Reference in New Issue
Block a user