Remove legacy sound code and simplify platform init.

This commit is contained in:
Paul Chote
2016-08-01 17:39:06 +01:00
parent de85a76c90
commit 9437a86e7e
9 changed files with 38 additions and 92 deletions

View File

@@ -12,20 +12,18 @@
using System.Drawing;
using OpenRA;
[assembly: Platform(typeof(OpenRA.Platforms.Default.DeviceFactory))]
namespace OpenRA.Platforms.Default
{
public class DeviceFactory : IDeviceFactory
public class DefaultPlatform : IPlatform
{
public IGraphicsDevice CreateGraphics(Size size, WindowMode windowMode)
{
return new Sdl2GraphicsDevice(size, windowMode);
}
public ISoundEngine CreateSound()
public ISoundEngine CreateSound(string device)
{
return new OpenAlSoundEngine();
return new OpenAlSoundEngine(device);
}
}
}

View File

@@ -24,11 +24,10 @@ namespace OpenRA.Platforms.Default
{
var defaultDevices = new[]
{
new SoundDevice("Default", null, "Default Output"),
new SoundDevice("Null", null, "Output Disabled")
new SoundDevice(null, "Default Output"),
};
var physicalDevices = PhysicalDevices().Select(d => new SoundDevice("Default", d, d));
var physicalDevices = PhysicalDevices().Select(d => new SoundDevice(d, d));
return defaultDevices.Concat(physicalDevices).ToArray();
}
@@ -86,16 +85,14 @@ namespace OpenRA.Platforms.Default
return new string[] { };
}
public OpenAlSoundEngine()
public OpenAlSoundEngine(string deviceName)
{
Console.WriteLine("Using OpenAL sound engine");
if (Game.Settings.Sound.Device != null)
Console.WriteLine("Using device `{0}`", Game.Settings.Sound.Device);
if (deviceName != null)
Console.WriteLine("Using sound device `{0}`", deviceName);
else
Console.WriteLine("Using default device");
Console.WriteLine("Using default sound device");
device = ALC10.alcOpenDevice(Game.Settings.Sound.Device);
device = ALC10.alcOpenDevice(deviceName);
if (device == IntPtr.Zero)
{
Console.WriteLine("Failed to open device. Falling back to default");