Made AudioContext.Device private. Added AudioContext.SupportsExtension.

This commit is contained in:
the_fiddler 2008-04-13 19:42:37 +00:00
parent 510125a0fa
commit d4590f183b
3 changed files with 37 additions and 19 deletions

View file

@ -16,7 +16,7 @@ using System.Diagnostics;
namespace Examples namespace Examples
{ {
[Example("AudioContext Test", ExampleCategory.Test)] [Example("AudioContext Test", ExampleCategory.Test, 0, false)]
class TestApp class TestApp
{ {
public static void PrintOpenALErrors( IntPtr device ) public static void PrintOpenALErrors( IntPtr device )
@ -65,21 +65,21 @@ namespace Examples
#region Get Attribs #region Get Attribs
int AttribCount; //int AttribCount;
Alc.GetInteger(context.Device, AlcGetInteger.AttributesSize, sizeof(int), out AttribCount); //Alc.GetInteger(context.Device, AlcGetInteger.AttributesSize, sizeof(int), out AttribCount);
Console.WriteLine("AttributeSize: " + AttribCount); //Console.WriteLine("AttributeSize: " + AttribCount);
if (AttribCount > 0) //if (AttribCount > 0)
{ //{
int[] Attribs = new int[AttribCount]; // int[] Attribs = new int[AttribCount];
Alc.GetInteger(context.Device, AlcGetInteger.AllAttributes, AttribCount, out Attribs[0]); // Alc.GetInteger(context.Device, AlcGetInteger.AllAttributes, AttribCount, out Attribs[0]);
for (int i = 0; i < Attribs.Length; i++) // for (int i = 0; i < Attribs.Length; i++)
{ // {
Console.Write(Attribs[i]); // Console.Write(Attribs[i]);
Console.Write(" "); // Console.Write(" ");
} // }
Console.WriteLine(); // Console.WriteLine();
} //}
#endregion Get Attribs #endregion Get Attribs

View file

@ -374,10 +374,13 @@ namespace OpenTK.Audio
#endregion #endregion
#region IntPtr Device
IntPtr Device { get { return device_handle.Handle; } }
#endregion #endregion
// TODO: Remove before release! #endregion
public IntPtr Device { get { return device_handle.Handle; } }
#region --- Public Members --- #region --- Public Members ---
@ -477,6 +480,21 @@ namespace OpenTK.Audio
#endregion #endregion
#region public bool SupportsExtension(string extension)
/// <summary>
/// Checks whether the specified OpenAL extension is supported.
/// </summary>
/// <param name="extension">The name of the extension to check (e.g. "ALC_EXT_EFX").</param>
/// <returns>true if the extension is supported; false otherwise.</returns>
public bool SupportsExtension(string extension)
{
if (disposed) throw new ObjectDisposedException(this.GetType().FullName);
return Alc.IsExtensionPresent(this.Device, extension);
}
#endregion
#region public static AudioContext CurrentContext #region public static AudioContext CurrentContext
/// <summary> /// <summary>

View file

@ -1138,9 +1138,9 @@ namespace OpenTK.Audio
if (AudioContext.CurrentContext == null) if (AudioContext.CurrentContext == null)
throw new InvalidOperationException("AL.LoadAll() needs a current AudioContext."); throw new InvalidOperationException("AL.LoadAll() needs a current AudioContext.");
if (Alc.IsExtensionPresent(AudioContext.CurrentContext.Device, "ALC_EXT_EFX") == false) if (!AudioContext.CurrentContext.SupportsExtension("ALC_EXT_EFX"))
{ {
Debug.WriteLine("EFX Extension (ALC_EXT_EFX) is not known to device: {0}.", AudioContext.CurrentContext.Device.ToString()); Debug.WriteLine("EFX Extension (ALC_EXT_EFX) is not supported(AudioContext: {0}).", AudioContext.CurrentContext.ToString());
return; return;
} }
// Console.WriteLine("ALC_EXT_EFX found. Efx can be used."); // Console.WriteLine("ALC_EXT_EFX found. Efx can be used.");