Added AudioCapture.IsRunning property.

Fixed formatting.
This commit is contained in:
the_fiddler 2009-07-19 20:55:18 +00:00
parent f1976edb8b
commit b19d7bf4c5
2 changed files with 278 additions and 247 deletions

View file

@ -52,39 +52,7 @@ namespace OpenTK.Audio
#endregion
#region Device Name
private string device_name;
/// <summary>The name of the device associated with this instance.</summary>
public string CurrentDeviceName
{
get
{
return device_name;
}
}
#endregion Device Name
#region public static properties
/// <summary>Returns a list of strings containing all known recording devices.</summary>
public static IList<string> AvailableDevices
{
get
{
return AudioDeviceEnumerator.AvailableRecordingDevices;
}
}
/// <summary>Returns the name of the device that will be used as recording default.</summary>
public static string DefaultDevice
{
get
{
return AudioDeviceEnumerator.DefaultRecordingDevice;
}
}
#endregion public static properties
#region Constructor
#region Constructors
static AudioCapture()
{
@ -111,6 +79,10 @@ namespace OpenTK.Audio
{
if (!AudioDeviceEnumerator.IsOpenALSupported)
throw new DllNotFoundException("openal32.dll");
if (frequency <= 0)
throw new ArgumentOutOfRangeException("frequency");
if (bufferSize <= 0)
throw new ArgumentOutOfRangeException("bufferSize");
// Try to open specified device. If it fails, try to open default device.
device_name = deviceName;
@ -148,40 +120,54 @@ namespace OpenTK.Audio
#endregion Constructor
#region IDisposable Members
#region Public Members
~AudioCapture()
#region CurrentDevice
private string device_name;
/// <summary>
/// The name of the device associated with this instance.
/// </summary>
public string CurrentDevice
{
Dispose();
}
private bool IsDisposed;
/// <summary>Closes the device and disposes the instance.</summary>
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool manual)
{
if (!this.IsDisposed)
get
{
if (this.Handle != IntPtr.Zero)
{
if (this._isrecording)
this.Stop();
Alc.CaptureCloseDevice(this.Handle);
}
this.IsDisposed = true;
return device_name;
}
}
#endregion Destructor
#endregion
#region Public Members
#region AvailableDevices
/// <summary>
/// Returns a list of strings containing all known recording devices.
/// </summary>
public static IList<string> AvailableDevices
{
get
{
return AudioDeviceEnumerator.AvailableRecordingDevices;
}
}
#endregion
#region DefaultDevice
/// <summary>
/// Returns the name of the device that will be used as recording default.
/// </summary>
public static string DefaultDevice
{
get
{
return AudioDeviceEnumerator.DefaultRecordingDevice;
}
}
#endregion
#region CheckErrors
@ -310,6 +296,18 @@ namespace OpenTK.Audio
#endregion
#region IsRunning
/// <summary>
/// Gets a value indicating whether this instance is currently capturing samples.
/// </summary>
public bool IsRunning
{
get { return _isrecording; }
}
#endregion
#endregion
#region Private Members
@ -375,5 +373,38 @@ namespace OpenTK.Audio
}
#endregion
#region IDisposable Members
~AudioCapture()
{
Dispose();
}
private bool IsDisposed;
/// <summary>Closes the device and disposes the instance.</summary>
public void Dispose()
{
this.Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool manual)
{
if (!this.IsDisposed)
{
if (this.Handle != IntPtr.Zero)
{
if (this._isrecording)
this.Stop();
Alc.CaptureCloseDevice(this.Handle);
}
this.IsDisposed = true;
}
}
#endregion Destructor
}
}