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; }
void Dispose(bool disposing) { if (device != IntPtr.Zero) { ALC10.alcCloseDevice(device); device = IntPtr.Zero; } }
protected override void Dispose(bool disposeManagedResources) { base.Dispose(disposeManagedResources); _sources.Clear(); _files.Clear(); ALC10.alcMakeContextCurrent(IntPtr.Zero); ALC10.alcDestroyContext(_context); ALC10.alcCloseDevice(_device); }
public void Dispose() { if (_context != IntPtr.Zero) { ALC10.alcMakeContextCurrent(IntPtr.Zero); Check(); ALC10.alcDestroyContext(_context); Check(); } if (_device != IntPtr.Zero) { ALC10.alcCloseDevice(_device); Check(); } }
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; } }
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; } }
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; } }
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; }
/// <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); }
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."); }