Esempio n. 1
0
 internal void DestroyContext(AlContext ctx)
 {
     if (!_contexts.Remove(ctx))
     {
         throw new InvalidOperationException("Device does not own given context.");
     }
     ALC10.alcMakeContextCurrent(IntPtr.Zero);
     ctx.Destroy();
 }
Esempio n. 2
0
        /// <summary>
        /// Create a context for this device.
        /// </summary>
        public AlContext CreateContext()
        {
            CheckDisposed();
            var ctxHandle = ALC10.alcCreateContext(_handle, new int[0]);

            if (ctxHandle == IntPtr.Zero)
            {
                AlHelper.AlcCheckError(_handle, "Failed to create context.");
                throw new Exception("Failed to create context.");
            }
            var ctx = new AlContext(this, ctxHandle);

            _contexts.Add(ctx);
            return(ctx);
        }
Esempio n. 3
0
        /// <summary>
        /// Create a managed wrapper for the specified audio playback device.
        /// Available devices can be queried with <see cref="GetDevices"/>.
        /// </summary>
        /// <param name="deviceName">Name of the device.</param>
        /// <exception cref="Exception">If opening the device or creating the context fails.</exception>
        private AlDevice(string deviceName)
        {
            Name    = deviceName ?? DefaultDeviceName;
            _handle = ALC10.alcOpenDevice(deviceName);
            if (_handle == IntPtr.Zero)
            {
                throw new Exception("Failed to open device.");
            }

            _contexts = new List <AlContext>();
            _buffers  = new List <uint>();

            var ctxHandle = ALC10.alcCreateContext(_handle, new int[0]);

            if (ctxHandle == IntPtr.Zero)
            {
                ALC10.alcCloseDevice(_handle);
                throw new Exception("Failed to create context.");
            }
            var ctx = new AlContext(this, ctxHandle);

            _contexts.Add(ctx);
        }
Esempio n. 4
0
 internal AlStreamingSource(uint name, AlContext context) : base(name, context)
 {
 }
Esempio n. 5
0
 internal AlStaticSource(uint name, AlContext context) : base(name, context)
 {
 }
Esempio n. 6
0
 /// <summary>
 /// Create an <see cref="AlSource"/>.
 /// </summary>
 /// <param name="name">Name of the source.</param>
 /// <param name="context">Context that owns the source.</param>
 protected AlSource(uint name, AlContext context)
 {
     Name    = name;
     Context = context;
 }