From 886d489766af415349c14603df38a1eaaa8b6841 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 5 Sep 2015 18:29:14 +0100 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20create=20multiple=20sound=20con?= =?UTF-8?q?texts.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenRA.Game/Game.cs | 4 +++- OpenRA.Game/Sound/Sound.cs | 11 +++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index bf0aa0cdab..efaaaf0f39 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -234,6 +234,8 @@ namespace OpenRA } } + Sound.Create(Settings.Server.Dedicated ? "Null" : Settings.Sound.Engine); + Console.WriteLine("Available mods:"); foreach (var mod in ModMetadata.AllMods) Console.WriteLine("\t{0}: {1} ({2})", mod.Key, mod.Value.Title, mod.Value.Version); @@ -275,7 +277,7 @@ namespace OpenRA Settings.Game.Mod = mod; Sound.StopVideo(); - Sound.Initialize(Settings.Server.Dedicated ? "Null" : Settings.Sound.Engine); + Sound.Initialize(); ModData = new ModData(mod, !Settings.Server.Dedicated); ModData.InitializeLoaders(); diff --git a/OpenRA.Game/Sound/Sound.cs b/OpenRA.Game/Sound/Sound.cs index e23df7d5b2..9ed73deefa 100644 --- a/OpenRA.Game/Sound/Sound.cs +++ b/OpenRA.Game/Sound/Sound.cs @@ -29,6 +29,12 @@ namespace OpenRA static ISound video; 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) { foreach (PlatformAttribute r in platformDll.GetCustomAttributes(typeof(PlatformAttribute), false)) @@ -66,11 +72,8 @@ namespace OpenRA 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(LoadSound); music = null; currentMusic = null;