From 662fcc1109a3718bb7d3301e8b5c193818446833 Mon Sep 17 00:00:00 2001 From: the_fiddler Date: Fri, 17 Jul 2009 23:07:17 +0000 Subject: [PATCH] Removed CurrentAlcError property. Fixed handling of ObjectDisposedExceptions. --- Source/OpenTK/Audio/AudioContext.cs | 105 ++++++++++++++++++---------- 1 file changed, 68 insertions(+), 37 deletions(-) diff --git a/Source/OpenTK/Audio/AudioContext.cs b/Source/OpenTK/Audio/AudioContext.cs index 3b9ed87f..a277e31b 100644 --- a/Source/OpenTK/Audio/AudioContext.cs +++ b/Source/OpenTK/Audio/AudioContext.cs @@ -430,6 +430,9 @@ namespace OpenTK.Audio /// Raised when an invalid context is detected. public void CheckErrors() { + if (disposed) + throw new ObjectDisposedException(this.GetType().FullName); + new AudioDeviceErrorChecker(device_handle).Dispose(); } @@ -437,18 +440,23 @@ namespace OpenTK.Audio #region CurrentError - /// Returns the ALC error code for this device. + /// + /// Returns the ALC error code for this instance. + /// public AlcError CurrentError { get { + if (disposed) + throw new ObjectDisposedException(this.GetType().FullName); + return Alc.GetError(device_handle); } } #endregion - #region public void MakeCurrent() + #region MakeCurrent /// Makes the AudioContext current in the calling thread. /// @@ -463,12 +471,15 @@ namespace OpenTK.Audio /// public void MakeCurrent() { + if (disposed) + throw new ObjectDisposedException(this.GetType().FullName); + AudioContext.MakeCurrent(this); } #endregion - #region public bool IsProcessing + #region IsProcessing /// /// Gets a System.Boolean indicating whether the AudioContext is @@ -478,13 +489,19 @@ namespace OpenTK.Audio /// public bool IsProcessing { - get { return is_processing; } + get + { + if (disposed) + throw new ObjectDisposedException(this.GetType().FullName); + + return is_processing; + } private set { is_processing = value; } } #endregion - #region public bool IsProcessing + #region IsSynchronized /// /// Gets a System.Boolean indicating whether the AudioContext is @@ -493,7 +510,13 @@ namespace OpenTK.Audio /// public bool IsSynchronized { - get { return is_synchronized; } + get + { + if (disposed) + throw new ObjectDisposedException(this.GetType().FullName); + + return is_synchronized; + } private set { is_synchronized = value; } } @@ -521,7 +544,9 @@ namespace OpenTK.Audio /// public void Process() { - if (disposed) throw new ObjectDisposedException(this.ToString()); + if (disposed) + throw new ObjectDisposedException(this.GetType().FullName); + Alc.ProcessContext(this.context_handle); IsProcessing = true; } @@ -552,7 +577,9 @@ namespace OpenTK.Audio /// public void Suspend() { - if (disposed) throw new ObjectDisposedException(this.ToString()); + if (disposed) + throw new ObjectDisposedException(this.GetType().FullName); + Alc.SuspendContext(this.context_handle); IsProcessing = false; } @@ -568,12 +595,36 @@ namespace OpenTK.Audio /// true if the extension is supported; false otherwise. public bool SupportsExtension(string extension) { - if (disposed) throw new ObjectDisposedException(this.GetType().FullName); + if (disposed) + throw new ObjectDisposedException(this.GetType().FullName); + return Alc.IsExtensionPresent(this.Device, extension); } #endregion + #region CurrentDevice + + /// + /// Gets a System.String with the name of the device used in this context. + /// + public string CurrentDevice + { + get + { + if (disposed) + throw new ObjectDisposedException(this.GetType().FullName); + + return device_name; + } + } + + #endregion + + #endregion --- Public Members --- + + #region --- Static Members --- + #region public static AudioContext CurrentContext /// @@ -606,7 +657,10 @@ namespace OpenTK.Audio #endregion #region AvailableDevices - /// Returns a list of strings containing all known playback devices. + + /// + /// Returns a list of strings containing all known playback devices. + /// public static IList AvailableDevices { get @@ -618,7 +672,9 @@ namespace OpenTK.Audio #region DefaultDevice - /// Returns the name of the device that will be used as playback default. + /// + /// Returns the name of the device that will be used as playback default. + /// public static string DefaultDevice { get @@ -629,32 +685,7 @@ namespace OpenTK.Audio #endregion - #region public string CurrentDeviceName - /// Returns the name of the used device for the current context. - public string CurrentDeviceName - { - get - { - return device_name; - } - } - #endregion public string CurrentDeviceName - - #region public AlcError CurrentAlcError - /// Returns the first encountered error by Alc for this device. - public AlcError CurrentAlcError - { - get - { - if (disposed) - throw new ObjectDisposedException(this.ToString()); - - return Alc.GetError(this.device_handle); - } - } - #endregion public AlcError CurrentAlcError - - #endregion --- Public Members --- + #endregion #region --- IDisposable Members ---