Temporarily removed detailed constructors.

This commit is contained in:
the_fiddler 2008-03-16 10:07:55 +00:00
parent b3d32793f3
commit aa21965023

View file

@ -53,10 +53,13 @@ namespace OpenTK.Audio
/// <summary>Constructs a new AudioContext, using the default audio device.</summary> /// <summary>Constructs a new AudioContext, using the default audio device.</summary>
/// <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) { }
{
CreateContext(null, 0, 0, false, 0);
}
#endregion #endregion
#if false
#region public AudioContext(string device) #region public AudioContext(string device)
/// <summary>Constructs a new AudioContext, using the specified audio device.</summary> /// <summary>Constructs a new AudioContext, using the specified audio device.</summary>
@ -149,10 +152,10 @@ namespace OpenTK.Audio
} }
#endregion #endregion
#endif
#endregion #endregion
#region --- Private Members --- #region --- Private Methods ---
#region static void LoadAvailableDevices() #region static void LoadAvailableDevices()
@ -170,10 +173,23 @@ namespace OpenTK.Audio
{ {
if (available_devices.Count == 0) if (available_devices.Count == 0)
{ {
if (Alc.IsExtensionPresent(IntPtr.Zero, "ALC_ENUMERATION_EXT")) try
available_devices.AddRange(Alc.GetString(IntPtr.Zero, AlcGetStringList.DeviceSpecifier)); {
else Debug.WriteLine("Enumerating audio devices.");
Debug.Print("Device enumeration extension not available. Failed to enumerate devices."); Debug.Indent();
if (Alc.IsExtensionPresent(IntPtr.Zero, "ALC_ENUMERATION_EXT"))
available_devices.AddRange(Alc.GetString(IntPtr.Zero, AlcGetStringList.DeviceSpecifier));
else
Debug.Print("Device enumeration extension not available. Failed to enumerate devices.");
foreach (string s in available_devices)
Debug.WriteLine(s);
}
finally
{
Debug.Unindent();
}
} }
} }
} }
@ -189,12 +205,11 @@ namespace OpenTK.Audio
/// <param name="refresh">Refresh intervals, in units of Hz. Pass 0 for driver default.</param> /// <param name="refresh">Refresh intervals, in units of Hz. Pass 0 for driver default.</param>
/// <param name="sync">Flag, indicating a synchronous context.</param> /// <param name="sync">Flag, indicating a synchronous context.</param>
/// <param name="maxEfxSends">Number of auxilliary send slots for the EFX extensions. Can be 0 (use driver default) or higher.</param> /// <param name="maxEfxSends">Number of auxilliary send slots for the EFX extensions. Can be 0 (use driver default) or higher.</param>
/// <exception cref="ArgumentNullException">Occurs when the device string is invalid.</exception>
/// /// <exception cref="ArgumentOutOfRangeException">Occurs when a specified parameter is invalid.</exception> /// /// <exception cref="ArgumentOutOfRangeException">Occurs when a specified parameter is invalid.</exception>
/// <exception cref="InvalidAudioDeviceException"> /// <exception cref="AudioDeviceException">
/// Occurs when the specified device is not available, or is in use by another program. /// Occurs when the specified device is not available, or is in use by another program.
/// </exception> /// </exception>
/// <exception cref="InvalidAudioContextException"> /// <exception cref="AudioDeviceException">
/// Occurs when an audio context could not be created with the specified parameters. /// Occurs when an audio context could not be created with the specified parameters.
/// </exception> /// </exception>
/// <exception cref="NotSupportedException"> /// <exception cref="NotSupportedException">
@ -210,14 +225,20 @@ namespace OpenTK.Audio
/// </remarks> /// </remarks>
void CreateContext(string device, int freq, int refresh, bool sync, int maxEfxSends) void CreateContext(string device, int freq, int refresh, bool sync, int maxEfxSends)
{ {
if (context_exists) throw new NotSupportedException("Multiple AudioContexts not supported."); if (available_devices.Count == 0) throw new NotSupportedException("No audio hardware is available.");
//if (String.IsNullOrEmpty(device)) throw new ArgumentNullException("device"); if (context_exists) throw new NotSupportedException("Multiple AudioContexts are not supported.");
if (freq < 0) throw new ArgumentOutOfRangeException("freq", freq, "Should be greater than zero."); if (freq < 0) throw new ArgumentOutOfRangeException("freq", freq, "Should be greater than zero.");
if (refresh < 0) throw new ArgumentOutOfRangeException("refresh", refresh, "Should be greater than zero."); if (refresh < 0) throw new ArgumentOutOfRangeException("refresh", refresh, "Should be greater than zero.");
if (maxEfxSends < 0) throw new ArgumentOutOfRangeException("maxEfxSends", maxEfxSends, "Should be greater than zero."); if (maxEfxSends < 0) throw new ArgumentOutOfRangeException("maxEfxSends", maxEfxSends, "Should be greater than zero.");
//if (available_devices.Count == 0) throw new NotSupportedException("No audio hardware is available.");
device_handle = Alc.OpenDevice(device); if (!String.IsNullOrEmpty(device))
device_handle = Alc.OpenDevice(device);
if (device_handle == IntPtr.Zero)
Alc.OpenDevice(Alc.GetString(IntPtr.Zero, AlcGetString.DefaultDeviceSpecifier));
if (device_handle == IntPtr.Zero && available_devices.Count > 0)
device_handle = Alc.OpenDevice(available_devices[0]);
if (device_handle == IntPtr.Zero)
device_handle = Alc.OpenDevice(null);
if (device_handle == IntPtr.Zero) if (device_handle == IntPtr.Zero)
throw new AudioDeviceException("The specified audio device does not exist or is tied up by another application."); throw new AudioDeviceException("The specified audio device does not exist or is tied up by another application.");
@ -512,13 +533,14 @@ namespace OpenTK.Audio
{ {
if (!disposed) if (!disposed)
{ {
available_contexts.Remove(this.context_handle);
if (this.IsCurrent) if (this.IsCurrent)
this.IsCurrent = false; this.IsCurrent = false;
if (context_handle != IntPtr.Zero) if (context_handle != IntPtr.Zero)
{
available_contexts.Remove(context_handle);
Alc.DestroyContext(context_handle); Alc.DestroyContext(context_handle);
}
if (device_handle != IntPtr.Zero) if (device_handle != IntPtr.Zero)
Alc.CloseDevice(device_handle); Alc.CloseDevice(device_handle);