Example #1
0
        public Context(Device device)
            : this()
        {
            if (device == Device.Null)
            {
                throw new ArgumentNullException("device");
            }

            unsafe
            {
                Handle = Alc.CreateContext(device.Handle, null);
                AlHelper.GetAlcError(Alc.GetError(device.Handle));
            }
        }
Example #2
0
        public Device(string name)
            : this()
        {
            unsafe
            {
                int   name_length = name == null ? 0 : Encoding.ASCII.GetByteCount(name);
                byte *name_ansi   = stackalloc byte[name_length + 1];
                AlHelper.StringToAnsi(name, name_ansi, name_length);
                name_ansi = name == null ? null : name_ansi;

                Handle = Alc.OpenDevice(name_ansi);
                if (Handle == IntPtr.Zero)
                {
                    throw new OpenALException(string.Format(
                                                  "OpenDevice({0}) failed.", name));
                }
            }
        }
Example #3
0
        public CaptureDevice(string name, uint frequency, Format format, int buffersize)
            : this()
        {
            unsafe
            {
                int   name_length = name == null ? 0 : Encoding.ASCII.GetByteCount(name);
                byte *name_ansi   = stackalloc byte[name_length + 1];
                AlHelper.StringToAnsi(name, name_ansi, name_length);
                name_ansi = name == null ? null : name_ansi;

                Handle = Alc.CaptureOpenDevice(name_ansi, frequency, (int)format, buffersize);
                if (Handle == IntPtr.Zero)
                {
                    throw new OpenALException(string.Format(
                                                  "CaptureOpenDevice({0}, {1}, {2}, {3}) failed.", name, frequency, format, buffersize));
                }
            }
        }
Example #4
0
 public void Stop()
 {
     AlHelper.ThrowNullException(Handle);
     Alc.CaptureStop(Handle);
     AlHelper.GetAlcError(Alc.GetError(Handle));
 }
Example #5
0
 public void Destroy()
 {
     AlHelper.ThrowNullException(Handle);
     Alc.DestroyContext(Handle);
 }
Example #6
0
 public static bool MakeContextCurrent(Context context)
 {
     return(Alc.MakeContextCurrent(context.Handle) != 0);
 }
Example #7
0
 public void Suspend()
 {
     AlHelper.ThrowNullException(Handle);
     Alc.SuspendContext(Handle);
 }
Example #8
0
 public void Process()
 {
     AlHelper.ThrowNullException(Handle);
     Alc.ProcessContext(Handle);
 }