Skip to content

Commit

Permalink
Use the correct DLL path for loading OpenAL
Browse files Browse the repository at this point in the history
  • Loading branch information
polsys committed Jan 21, 2017
1 parent d39a7fa commit 2ce14bb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
6 changes: 5 additions & 1 deletion MonoGame.Framework/Audio/OpenALSoundController.cs
Expand Up @@ -113,7 +113,11 @@ internal sealed class OpenALSoundController : IDisposable
/// Sets up the hardware resources used by the controller.
/// </summary>
private OpenALSoundController()
{
{
// On Windows, set the DLL search path for correct native binaries
if (PlatformParameters.DetectWindowsArchitecture)
NativeHelper.InitDllDirectory();

if (!OpenSoundController())
{
return;
Expand Down
12 changes: 8 additions & 4 deletions MonoGame.Framework/Utilities/CurrentPlatform.cs
Expand Up @@ -99,11 +99,13 @@ public static class PlatformParameters
internal static class NativeHelper
{
[DllImport("kernel32.dll", SetLastError = true)]
private static extern bool SetDllDirectory(string lpPathName);

private static extern bool SetDllDirectory(string lpPathName);

private static bool _dllDirectorySet = false;

public static void InitDllDirectory()
{
if (CurrentPlatform.OS == OS.Windows)
if (CurrentPlatform.OS == OS.Windows && !_dllDirectorySet)
{
string executingDirectory = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
if (Environment.Is64BitProcess)
Expand All @@ -113,7 +115,9 @@ public static void InitDllDirectory()
else
{
NativeHelper.SetDllDirectory(System.IO.Path.Combine(executingDirectory, "x86"));
}
}

_dllDirectorySet = true;
}
}
}
Expand Down

0 comments on commit 2ce14bb

Please sign in to comment.