diff --git a/Makefile b/Makefile
index 7f753cee2d..46f775589e 100644
--- a/Makefile
+++ b/Makefile
@@ -80,7 +80,7 @@ VERSION = $(shell git name-rev --name-only --tags --no-undefined HEAD 2>/dev
game_SRCS := $(shell find OpenRA.Game/ -iname '*.cs')
game_TARGET = OpenRA.Game.exe
game_KIND = winexe
-game_LIBS = $(COMMON_LIBS) $(game_DEPS) thirdparty/Tao/Tao.OpenAl.dll thirdparty/SharpFont.dll
+game_LIBS = $(COMMON_LIBS) $(game_DEPS) thirdparty/SDL2-CS.dll thirdparty/SharpFont.dll
game_FLAGS = -win32icon:OpenRA.Game/OpenRA.ico
PROGRAMS += game
game: $(game_TARGET)
diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj
index 1e3083e1e6..b5d52232e0 100644
--- a/OpenRA.Game/OpenRA.Game.csproj
+++ b/OpenRA.Game/OpenRA.Game.csproj
@@ -76,10 +76,6 @@
..\thirdparty\Eluant.dll
-
- False
- ..\thirdparty\Tao\Tao.OpenAl.dll
-
..\thirdparty\ICSharpCode.SharpZipLib.dll
@@ -89,6 +85,9 @@
..\thirdparty\MaxMind.Db.dll
+
+ ..\thirdparty\SDL2-CS.dll
+
diff --git a/OpenRA.Game/Sound.cs b/OpenRA.Game/Sound.cs
index e54fbf4611..8f4ea93c54 100644
--- a/OpenRA.Game/Sound.cs
+++ b/OpenRA.Game/Sound.cs
@@ -16,7 +16,8 @@ using OpenRA.FileSystem;
using OpenRA.GameRules;
using OpenRA.Primitives;
using OpenRA.Traits;
-using Tao.OpenAl;
+using OpenTK;
+using OpenTK.Audio.OpenAL;
namespace OpenRA
{
@@ -449,13 +450,13 @@ namespace OpenRA
float volume = 1f;
Dictionary sourcePool = new Dictionary();
- static string[] QueryDevices(string label, int type)
+ static string[] QueryDevices(string label, AlcGetStringList type)
{
// Clear error bit
- Al.alGetError();
+ AL.GetError();
- var devices = Alc.alcGetStringv(IntPtr.Zero, type);
- if (Al.alGetError() != Al.AL_NO_ERROR)
+ var devices = Alc.GetString(IntPtr.Zero, type).ToArray();
+ if (AL.GetError() != ALError.NoError)
{
Log.Write("sound", "Failed to query OpenAL device list using {0}", label);
return new string[] { };
@@ -466,12 +467,12 @@ namespace OpenRA
public static string[] AvailableDevices()
{
- // Returns all devices under windows vista and newer
- if (Alc.alcIsExtensionPresent(IntPtr.Zero, "ALC_ENUMERATE_ALL_EXT") == Alc.ALC_TRUE)
- return QueryDevices("ALC_ENUMERATE_ALL_EXT", Alc.ALC_ALL_DEVICES_SPECIFIER);
+ // Returns all devices under Windows Vista and newer
+ if (Alc.IsExtensionPresent(IntPtr.Zero, "ALC_ENUMERATE_ALL_EXT"))
+ return QueryDevices("ALC_ENUMERATE_ALL_EXT", AlcGetStringList.AllDevicesSpecifier);
- if (Alc.alcIsExtensionPresent(IntPtr.Zero, "ALC_ENUMERATION_EXT") == Alc.ALC_TRUE)
- return QueryDevices("ALC_ENUMERATION_EXT", Alc.ALC_DEVICE_SPECIFIER);
+ if (Alc.IsExtensionPresent(IntPtr.Zero, "ALC_ENUMERATION_EXT"))
+ return QueryDevices("ALC_ENUMERATION_EXT", AlcGetStringList.DeviceSpecifier);
return new string[] { };
}
@@ -485,25 +486,25 @@ namespace OpenRA
else
Console.WriteLine("Using default device");
- var dev = Alc.alcOpenDevice(Game.Settings.Sound.Device);
+ var dev = Alc.OpenDevice(Game.Settings.Sound.Device);
if (dev == IntPtr.Zero)
{
Console.WriteLine("Failed to open device. Falling back to default");
- dev = Alc.alcOpenDevice(null);
+ dev = Alc.OpenDevice(null);
if (dev == IntPtr.Zero)
throw new InvalidOperationException("Can't create OpenAL device");
}
- var ctx = Alc.alcCreateContext(dev, IntPtr.Zero);
- if (ctx == IntPtr.Zero)
+ var ctx = Alc.CreateContext(dev, (int[])null);
+ if (ctx == ContextHandle.Zero)
throw new InvalidOperationException("Can't create OpenAL context");
- Alc.alcMakeContextCurrent(ctx);
+ Alc.MakeContextCurrent(ctx);
for (var i = 0; i < PoolSize; i++)
{
var source = 0;
- Al.alGenSources(1, out source);
- if (0 != Al.alGetError())
+ AL.GenSources(1, out source);
+ if (0 != AL.GetError())
{
Log.Write("sound", "Failed generating OpenAL source {0}", i);
return;
@@ -528,8 +529,8 @@ namespace OpenRA
foreach (int key in sourcePool.Keys)
{
int state;
- Al.alGetSourcei(key, Al.AL_SOURCE_STATE, out state);
- if (state != Al.AL_PLAYING && state != Al.AL_PAUSED)
+ AL.GetSource(key, ALGetSourcei.SourceState, out state);
+ if (state != (int)ALSourceState.Playing && state != (int)ALSourceState.Paused)
freeSources.Add(key);
}
@@ -606,7 +607,7 @@ namespace OpenRA
public float Volume
{
get { return volume; }
- set { Al.alListenerf(Al.AL_GAIN, volume = value); }
+ set { AL.Listener(ALListenerf.Gain, volume = value); }
}
public void PauseSound(ISound sound, bool paused)
@@ -616,11 +617,11 @@ namespace OpenRA
var key = ((OpenAlSound)sound).Source;
int state;
- Al.alGetSourcei(key, Al.AL_SOURCE_STATE, out state);
- if (state == Al.AL_PLAYING && paused)
- Al.alSourcePause(key);
- else if (state == Al.AL_PAUSED && !paused)
- Al.alSourcePlay(key);
+ AL.GetSource(key, ALGetSourcei.SourceState, out state);
+ if (state == (int)ALSourceState.Playing && paused)
+ AL.SourcePause(key);
+ else if (state == (int)ALSourceState.Paused && !paused)
+ AL.SourcePlay(key);
}
public void SetAllSoundsPaused(bool paused)
@@ -628,11 +629,11 @@ namespace OpenRA
foreach (var key in sourcePool.Keys)
{
int state;
- Al.alGetSourcei(key, Al.AL_SOURCE_STATE, out state);
- if (state == Al.AL_PLAYING && paused)
- Al.alSourcePause(key);
- else if (state == Al.AL_PAUSED && !paused)
- Al.alSourcePlay(key);
+ AL.GetSource(key, ALGetSourcei.SourceState, out state);
+ if (state == (int)ALSourceState.Playing && paused)
+ AL.SourcePause(key);
+ else if (state == (int)ALSourceState.Paused && !paused)
+ AL.SourcePlay(key);
}
}
@@ -641,14 +642,14 @@ namespace OpenRA
var sounds = sourcePool.Select(s => s.Key).Where(b =>
{
int state;
- Al.alGetSourcei(b, Al.AL_SOURCE_STATE, out state);
- return (state == Al.AL_PLAYING || state == Al.AL_PAUSED) &&
+ AL.GetSource(b, ALGetSourcei.SourceState, out state);
+ return (state == (int)ALSourceState.Playing || state == (int)ALSourceState.Paused) &&
(music == null || b != ((OpenAlSound)music).Source) &&
(video == null || b != ((OpenAlSound)video).Source);
});
foreach (var s in sounds)
- Al.alSourcef(s, Al.AL_GAIN, volume);
+ AL.Source(s, ALSourcef.Gain, volume);
}
public void StopSound(ISound sound)
@@ -658,9 +659,9 @@ namespace OpenRA
var key = ((OpenAlSound)sound).Source;
int state;
- Al.alGetSourcei(key, Al.AL_SOURCE_STATE, out state);
- if (state == Al.AL_PLAYING || state == Al.AL_PAUSED)
- Al.alSourceStop(key);
+ AL.GetSource(key, ALGetSourcei.SourceState, out state);
+ if (state == (int)ALSourceState.Playing || state == (int)ALSourceState.Paused)
+ AL.SourceStop(key);
}
public void StopAllSounds()
@@ -668,20 +669,20 @@ namespace OpenRA
foreach (var key in sourcePool.Keys)
{
int state;
- Al.alGetSourcei(key, Al.AL_SOURCE_STATE, out state);
- if (state == Al.AL_PLAYING || state == Al.AL_PAUSED)
- Al.alSourceStop(key);
+ AL.GetSource(key, ALGetSourcei.SourceState, out state);
+ if (state == (int)ALSourceState.Playing || state == (int)ALSourceState.Paused)
+ AL.SourceStop(key);
}
}
public void SetListenerPosition(WPos position)
{
// Move the listener out of the plane so that sounds near the middle of the screen aren't too positional
- Al.alListener3f(Al.AL_POSITION, position.X, position.Y, position.Z + 2133);
+ AL.Listener(ALListener3f.Position, position.X, position.Y, position.Z + 2133);
var orientation = new[] { 0f, 0f, 1f, 0f, -1f, 0f };
- Al.alListenerfv(Al.AL_ORIENTATION, ref orientation[0]);
- Al.alListenerf(Al.AL_METERS_PER_UNIT, .01f);
+ AL.Listener(ALListenerfv.Orientation, ref orientation);
+ AL.Listener(ALListenerf.EfxMetersPerUnit, .01f);
}
}
@@ -689,18 +690,18 @@ namespace OpenRA
{
public readonly int Buffer;
- static int MakeALFormat(int channels, int bits)
+ static ALFormat MakeALFormat(int channels, int bits)
{
if (channels == 1)
- return bits == 16 ? Al.AL_FORMAT_MONO16 : Al.AL_FORMAT_MONO8;
+ return bits == 16 ? ALFormat.Mono16 : ALFormat.Mono8;
else
- return bits == 16 ? Al.AL_FORMAT_STEREO16 : Al.AL_FORMAT_STEREO8;
+ return bits == 16 ? ALFormat.Stereo16 : ALFormat.Stereo8;
}
public OpenAlSoundSource(byte[] data, int channels, int sampleBits, int sampleRate)
{
- Al.alGenBuffers(1, out Buffer);
- Al.alBufferData(Buffer, MakeALFormat(channels, sampleBits), data, data.Length, sampleRate);
+ AL.GenBuffers(1, out Buffer);
+ AL.BufferData(Buffer, MakeALFormat(channels, sampleBits), data, data.Length, sampleRate);
}
}
@@ -717,16 +718,16 @@ namespace OpenRA
Source = source;
Volume = volume;
- Al.alSourcef(source, Al.AL_PITCH, 1f);
- Al.alSource3f(source, Al.AL_POSITION, pos.X, pos.Y, pos.Z);
- Al.alSource3f(source, Al.AL_VELOCITY, 0f, 0f, 0f);
- Al.alSourcei(source, Al.AL_BUFFER, buffer);
- Al.alSourcei(source, Al.AL_LOOPING, looping ? Al.AL_TRUE : Al.AL_FALSE);
- Al.alSourcei(source, Al.AL_SOURCE_RELATIVE, relative ? 1 : 0);
+ AL.Source(source, ALSourcef.Pitch, 1f);
+ AL.Source(source, ALSource3f.Position, pos.X, pos.Y, pos.Z);
+ AL.Source(source, ALSource3f.Velocity, 0f, 0f, 0f);
+ AL.Source(source, ALSourcei.Buffer, buffer);
+ AL.Source(source, ALSourceb.Looping, looping);
+ AL.Source(source, ALSourceb.SourceRelative, relative);
- Al.alSourcef(source, Al.AL_REFERENCE_DISTANCE, 6826);
- Al.alSourcef(source, Al.AL_MAX_DISTANCE, 136533);
- Al.alSourcePlay(source);
+ AL.Source(source, ALSourcef.ReferenceDistance, 6826);
+ AL.Source(source, ALSourcef.MaxDistance, 136533);
+ AL.SourcePlay(source);
}
public float Volume
@@ -739,7 +740,7 @@ namespace OpenRA
set
{
if (Source != -1)
- Al.alSourcef(Source, Al.AL_GAIN, volume = value);
+ AL.Source(Source, ALSourcef.Gain, volume = value);
}
}
@@ -747,8 +748,8 @@ namespace OpenRA
{
get
{
- float pos;
- Al.alGetSourcef(Source, Al.AL_SAMPLE_OFFSET, out pos);
+ int pos;
+ AL.GetSource(Source, ALGetSourcei.SampleOffset, out pos);
return pos / 22050f;
}
}
@@ -758,8 +759,8 @@ namespace OpenRA
get
{
int state;
- Al.alGetSourcei(Source, Al.AL_SOURCE_STATE, out state);
- return state == Al.AL_PLAYING;
+ AL.GetSource(Source, ALGetSourcei.SourceState, out state);
+ return state == (int)ALSourceState.Playing;
}
}
}
diff --git a/packaging/windows/OpenRA.nsi b/packaging/windows/OpenRA.nsi
index 070ecb245c..7377fa7975 100644
--- a/packaging/windows/OpenRA.nsi
+++ b/packaging/windows/OpenRA.nsi
@@ -93,7 +93,7 @@ Section "Game" GAME
File "${SRCDIR}\KopiLua.dll"
File "${SRCDIR}\NLua.dll"
File "${SRCDIR}\eluant.dll"
- File "${DEPSDIR}\OpenAL32.dll"
+ File "${DEPSDIR}\soft_oal.dll"
File "${DEPSDIR}\SDL2.dll"
File "${DEPSDIR}\freetype6.dll"
File "${DEPSDIR}\zlib1.dll"
@@ -214,7 +214,7 @@ Function ${UN}Clean
Delete $INSTDIR\KopiLua.dll
Delete $INSTDIR\NLua.dll
Delete $INSTDIR\SDL2-CS.dll
- Delete $INSTDIR\OpenAL32.dll
+ Delete $INSTDIR\soft_oal.dll
Delete $INSTDIR\SDL2.dll
Delete $INSTDIR\lua51.dll
Delete $INSTDIR\eluant.dll
diff --git a/thirdparty/SDL2-CS.dll.config b/thirdparty/SDL2-CS.dll.config
index 7ebda83a28..e7ebbb513f 100644
--- a/thirdparty/SDL2-CS.dll.config
+++ b/thirdparty/SDL2-CS.dll.config
@@ -3,4 +3,7 @@
+
+
+
diff --git a/thirdparty/Tao/Tao.OpenAl.dll b/thirdparty/Tao/Tao.OpenAl.dll
deleted file mode 100644
index c45c0d083c..0000000000
Binary files a/thirdparty/Tao/Tao.OpenAl.dll and /dev/null differ
diff --git a/thirdparty/Tao/Tao.OpenAl.dll.config b/thirdparty/Tao/Tao.OpenAl.dll.config
deleted file mode 100644
index cafbeba30e..0000000000
--- a/thirdparty/Tao/Tao.OpenAl.dll.config
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/thirdparty/windows/OpenAL32.dll b/thirdparty/windows/soft_oal.dll
similarity index 100%
rename from thirdparty/windows/OpenAL32.dll
rename to thirdparty/windows/soft_oal.dll