From ea22820118d351db112a0b5b3aa39e6d9f00a6f4 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Sun, 13 Apr 2008 15:50:22 +0000 Subject: [PATCH] Improved handling of missing openal32.dll. It used to throw a TypeInitializationException. It now throws a DllNotFoundException. --- Source/OpenTK/Audio/AudioContext.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/OpenTK/Audio/AudioContext.cs b/Source/OpenTK/Audio/AudioContext.cs index b5a876ac..b666db73 100644 --- a/Source/OpenTK/Audio/AudioContext.cs +++ b/Source/OpenTK/Audio/AudioContext.cs @@ -29,6 +29,7 @@ namespace OpenTK.Audio static object audio_context_lock = new object(); static List available_devices = new List(); static Dictionary available_contexts = new Dictionary(); + static bool openal_supported = true; bool context_exists; #endregion @@ -55,6 +56,8 @@ namespace OpenTK.Audio /// Occurs when no audio devices are available. public AudioContext()// : this(available_devices.Count > 0 ? available_devices[0] : null, 0, 0, false, 0) { } { + if (!openal_supported) + throw new DllNotFoundException("openal32.dll"); CreateContext(null, 0, 0, false, 0); } @@ -186,6 +189,11 @@ namespace OpenTK.Audio foreach (string s in available_devices) Debug.WriteLine(s); } + catch (DllNotFoundException e) + { + Debug.WriteLine(e.ToString()); + openal_supported = false; + } finally { Debug.Unindent();