Don’t create multiple sound contexts.

This commit is contained in:
Paul Chote
2015-09-05 18:29:14 +01:00
parent e74c0d6c13
commit 886d489766
2 changed files with 10 additions and 5 deletions

View File

@@ -234,6 +234,8 @@ namespace OpenRA
} }
} }
Sound.Create(Settings.Server.Dedicated ? "Null" : Settings.Sound.Engine);
Console.WriteLine("Available mods:"); Console.WriteLine("Available mods:");
foreach (var mod in ModMetadata.AllMods) foreach (var mod in ModMetadata.AllMods)
Console.WriteLine("\t{0}: {1} ({2})", mod.Key, mod.Value.Title, mod.Value.Version); Console.WriteLine("\t{0}: {1} ({2})", mod.Key, mod.Value.Title, mod.Value.Version);
@@ -275,7 +277,7 @@ namespace OpenRA
Settings.Game.Mod = mod; Settings.Game.Mod = mod;
Sound.StopVideo(); Sound.StopVideo();
Sound.Initialize(Settings.Server.Dedicated ? "Null" : Settings.Sound.Engine); Sound.Initialize();
ModData = new ModData(mod, !Settings.Server.Dedicated); ModData = new ModData(mod, !Settings.Server.Dedicated);
ModData.InitializeLoaders(); ModData.InitializeLoaders();

View File

@@ -29,6 +29,12 @@ namespace OpenRA
static ISound video; static ISound video;
static MusicInfo currentMusic; static MusicInfo currentMusic;
public static void Create(string engineName)
{
var enginePath = Platform.ResolvePath(".", "OpenRA.Platforms." + engineName + ".dll");
soundEngine = CreateDevice(Assembly.LoadFile(enginePath));
}
static ISoundEngine CreateDevice(Assembly platformDll) static ISoundEngine CreateDevice(Assembly platformDll)
{ {
foreach (PlatformAttribute r in platformDll.GetCustomAttributes(typeof(PlatformAttribute), false)) foreach (PlatformAttribute r in platformDll.GetCustomAttributes(typeof(PlatformAttribute), false))
@@ -66,11 +72,8 @@ namespace OpenRA
return soundEngine.AddSoundSourceFromMemory(rawData, channels, sampleBits, sampleRate); return soundEngine.AddSoundSourceFromMemory(rawData, channels, sampleBits, sampleRate);
} }
public static void Initialize(string engineName) public static void Initialize()
{ {
var enginePath = Platform.ResolvePath(".", "OpenRA.Platforms." + engineName + ".dll");
soundEngine = CreateDevice(Assembly.LoadFile(enginePath));
sounds = new Cache<string, ISoundSource>(LoadSound); sounds = new Cache<string, ISoundSource>(LoadSound);
music = null; music = null;
currentMusic = null; currentMusic = null;