Improved handling of missing openal32.dll. It used to throw a TypeInitializationException. It now throws a DllNotFoundException.
This commit is contained in:
parent
037761c764
commit
23ed50e322
1 changed files with 8 additions and 0 deletions
|
@ -29,6 +29,7 @@ namespace OpenTK.Audio
|
||||||
static object audio_context_lock = new object();
|
static object audio_context_lock = new object();
|
||||||
static List<string> available_devices = new List<string>();
|
static List<string> available_devices = new List<string>();
|
||||||
static Dictionary<ContextHandle, AudioContext> available_contexts = new Dictionary<ContextHandle, AudioContext>();
|
static Dictionary<ContextHandle, AudioContext> available_contexts = new Dictionary<ContextHandle, AudioContext>();
|
||||||
|
static bool openal_supported = true;
|
||||||
bool context_exists;
|
bool context_exists;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -55,6 +56,8 @@ namespace OpenTK.Audio
|
||||||
/// <exception cref="NotSupportedException">Occurs when no audio devices are available.</exception>
|
/// <exception cref="NotSupportedException">Occurs when no audio devices are available.</exception>
|
||||||
public AudioContext()// : this(available_devices.Count > 0 ? available_devices[0] : null, 0, 0, false, 0) { }
|
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);
|
CreateContext(null, 0, 0, false, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,6 +189,11 @@ namespace OpenTK.Audio
|
||||||
foreach (string s in available_devices)
|
foreach (string s in available_devices)
|
||||||
Debug.WriteLine(s);
|
Debug.WriteLine(s);
|
||||||
}
|
}
|
||||||
|
catch (DllNotFoundException e)
|
||||||
|
{
|
||||||
|
Debug.WriteLine(e.ToString());
|
||||||
|
openal_supported = false;
|
||||||
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Debug.Unindent();
|
Debug.Unindent();
|
||||||
|
|
Loading…
Reference in a new issue