00001 #region License
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #endregion
00027
00028 using System;
00029 using System.Collections.Generic;
00030 using System.Text;
00031
00032 using OpenTK.Audio.OpenAL;
00033
00034 namespace OpenTK.Audio
00035 {
00036 struct AudioDeviceErrorChecker : IDisposable
00037 {
00038 #region Fields
00039
00040 readonly IntPtr Device;
00041 static readonly string ErrorString = "Device {0} reported {1}.";
00042
00043 #endregion
00044
00045 #region Constructors
00046
00047 public AudioDeviceErrorChecker(IntPtr device)
00048 {
00049 if (device == IntPtr.Zero)
00050 throw new AudioDeviceException();
00051
00052 Device = device;
00053 }
00054
00055 #endregion
00056
00057 #region IDisposable Members
00058
00059 public void Dispose()
00060 {
00061 AlcError err = Alc.GetError(Device);
00062 switch (err)
00063 {
00064 case AlcError.OutOfMemory:
00065 throw new OutOfMemoryException(String.Format(ErrorString, Device, err));
00066
00067 case AlcError.InvalidValue:
00068 throw new AudioValueException(String.Format(ErrorString, Device, err));
00069
00070 case AlcError.InvalidDevice:
00071 throw new AudioDeviceException(String.Format(ErrorString, Device, err));
00072
00073 case AlcError.InvalidContext:
00074 throw new AudioContextException(String.Format(ErrorString, Device, err));
00075
00076 case AlcError.NoError:
00077 default:
00078
00079 break;
00080 }
00081 }
00082
00083 #endregion
00084 }
00085 }