Esempio n. 1
0
        private void ReleaseUnmanagedResources()
        {
            if (_disposed)
            {
                return;
            }

            ALC10.alcMakeContextCurrent(MainContext.Handle);
            for (var i = 0; i < _buffers.Count; i++)
            {
                var buf = _buffers[i];
                AL10.alDeleteBuffers(_buffers.Count, ref buf);
            }
            _buffers.Clear();

            ALC10.alcMakeContextCurrent(IntPtr.Zero);
            foreach (var ctx in _contexts)
            {
                ctx.Destroy();
            }

            ALC10.alcCloseDevice(_handle);

            _disposed = true;
        }
Esempio n. 2
0
 void Dispose(bool disposing)
 {
     if (device != IntPtr.Zero)
     {
         ALC10.alcCloseDevice(device);
         device = IntPtr.Zero;
     }
 }
Esempio n. 3
0
        protected override void Dispose(bool disposeManagedResources)
        {
            base.Dispose(disposeManagedResources);
            _sources.Clear();
            _files.Clear();


            ALC10.alcMakeContextCurrent(IntPtr.Zero);
            ALC10.alcDestroyContext(_context);
            ALC10.alcCloseDevice(_device);
        }
Esempio n. 4
0
        public void Dispose()
        {
            if (_context != IntPtr.Zero)
            {
                ALC10.alcMakeContextCurrent(IntPtr.Zero); Check();
                ALC10.alcDestroyContext(_context); Check();
            }

            if (_device != IntPtr.Zero)
            {
                ALC10.alcCloseDevice(_device);
                Check();
            }
        }
Esempio n. 5
0
 public void Dispose()
 {
     ALC10.alcMakeContextCurrent(IntPtr.Zero);
     if (alContext != IntPtr.Zero)
     {
         ALC10.alcDestroyContext(alContext);
         alContext = IntPtr.Zero;
     }
     if (alDevice != IntPtr.Zero)
     {
         ALC10.alcCloseDevice(alDevice);
         alDevice = IntPtr.Zero;
     }
 }
Esempio n. 6
0
        void Dispose(bool disposing)
        {
            if (context != IntPtr.Zero)
            {
                ALC10.alcMakeContextCurrent(IntPtr.Zero);
                ALC10.alcDestroyContext(context);
                context = IntPtr.Zero;
            }

            if (device != IntPtr.Zero)
            {
                ALC10.alcCloseDevice(device);
                device = IntPtr.Zero;
            }
        }
Esempio n. 7
0
        public void Dispose()
        {
            EFX.alDeleteFilters(1, ref INTERNAL_alFilter);

            ALC10.alcMakeContextCurrent(IntPtr.Zero);
            if (alContext != IntPtr.Zero)
            {
                ALC10.alcDestroyContext(alContext);
                alContext = IntPtr.Zero;
            }
            if (alDevice != IntPtr.Zero)
            {
                ALC10.alcCloseDevice(alDevice);
                alDevice = IntPtr.Zero;
            }
        }
Esempio n. 8
0
        void InnerDispose()
        {
            if (_disposed)
            {
                return;
            }

            if (_context != IntPtr.Zero)
            {
                ALC10.alcMakeContextCurrent(IntPtr.Zero); Check();
                ALC10.alcDestroyContext(_context); Check();
            }

            if (_device != IntPtr.Zero)
            {
                ALC10.alcCloseDevice(_device);
                Check();
            }

            _disposed = true;
        }
Esempio n. 9
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. 10
0
        public static void Shutdown()
        {
            // Destroy the sources
            AL10.alDeleteSources(MAX_SOURCE_COUNT, s_allSources);
            ALUtils.CheckALError("unable to free audio sources");
            s_availableSources.Clear();
            s_usedSources.Clear();

            // Destroy the context, and then close the device
            ALC10.alcMakeContextCurrent(IntPtr.Zero);
            ALUtils.CheckALCError();
            ALC10.alcDestroyContext(Context);
            ALUtils.CheckALCError();
            Context = IntPtr.Zero;
            ALC10.alcCloseDevice(Device);
            ALUtils.CheckALCError();
            Device = IntPtr.Zero;

            IsShutdown = true;

            // Report
            LINFO("Shutdown OpenAL audio engine.");
        }