From a4efc490b3da04338de9371dac1e5f541048b791 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Sun, 20 Jan 2008 22:42:49 +0000 Subject: [PATCH] Re-added MakeCurrent() call. Added better error checking. --- Source/OpenTK/OpenAL/AudioContext.cs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/Source/OpenTK/OpenAL/AudioContext.cs b/Source/OpenTK/OpenAL/AudioContext.cs index 10034439..c3bfc93d 100644 --- a/Source/OpenTK/OpenAL/AudioContext.cs +++ b/Source/OpenTK/OpenAL/AudioContext.cs @@ -212,6 +212,8 @@ namespace OpenTK.Audio if (device_handle == IntPtr.Zero) throw new AudioDeviceException("The specified audio device does not exist or is tied up by another application."); + CheckForAlcErrors(); + device_name = device; /* // Build the attribute list @@ -249,12 +251,12 @@ namespace OpenTK.Audio throw new AudioContextException("The audio context could not be created with the specified parameters."); } - //MakeCurrent(); + CheckForAlcErrors(); - AlcError err = Alc.GetError(device_handle); - if (err != AlcError.NoError) - throw new AudioContextException(err.ToString()); + MakeCurrent(); + CheckForAlcErrors(); + //device_name = Alc.GetString(device_handle, AlcGetString.DeviceSpecifier); //Debug.Print(device_name); lock (audio_context_lock) @@ -265,6 +267,17 @@ namespace OpenTK.Audio #endregion + #region void CheckForAlcErrors() + + void CheckForAlcErrors() + { + AlcError err = Alc.GetError(device_handle); + if (err != AlcError.NoError) + throw new AudioContextException(err.ToString()); + } + + #endregion + #region static void MakeCurrent(AudioContext context) /// @@ -278,7 +291,7 @@ namespace OpenTK.Audio /// static void MakeCurrent(AudioContext context) { - //lock (audio_context_lock) + lock (audio_context_lock) { if (!Alc.MakeContextCurrent(context != null ? (IntPtr)context.context_handle : IntPtr.Zero)) throw new AudioContextException(Alc.GetError(