public unsafe void UpdateAudio(byte[] samples) { int processed = 0; int alBuffer = 0; while (true) { AL.GetSource(audioSource, ALGetSourcei.BuffersProcessed, out processed); while (processed-- > 0) { AL.SourceUnqueueBuffers(audioSource, 1, ref alBuffer); AL.DeleteBuffer(alBuffer); queueLength--; } if (queueLength < 5 || fastForward) { break; } } if (queueLength < 5) { alBuffer = AL.GenBuffer(); AL.BufferData(alBuffer, ALFormat.Stereo16, samples, 44100); AL.SourceQueueBuffer(audioSource, alBuffer); queueLength++; } if (AL.GetSourceState(audioSource) != ALSourceState.Playing) { AL.SourcePlay(audioSource); } }
public static void ClearResources() { foreach (Geometry value in geometryDictionary.Values) { value.Delete(); } geometryDictionary.Clear(); foreach (int value in textureDictionary.Values) { GL.DeleteTexture(value); } textureDictionary.Clear(); foreach (int value in audioDictionary.Values) { AL.DeleteBuffer(value); } audioDictionary.Clear(); foreach (Shader value in shaderDictionary.Values) { value.Delete(); } shaderDictionary.Clear(); }
public static void Dispose() { foreach (var clip in AudioClip.AudioClips) { AL.DeleteBuffer(clip.BufferID); } }
/// <summary> /// Деструктор /// </summary> public void Dispose() { AL.DeleteSource(AlSource); AL.DeleteBuffer(AlBuffer); Console.WriteLine($"AL: Audio data {AlSource}:{AlBuffer} removed from memory"); }
/// <summary> /// Cleans Up all resources /// </summary> public static void CleanUp() { foreach (var t in textureDictionary) { t.Value.Delete(); } textureDictionary.Clear(); foreach (var s in shaderDictionary) { s.Value.Delete(); } shaderDictionary.Clear(); foreach (var g in geometryDictionary) { g.Value.CleanUp(); } geometryDictionary.Clear(); foreach (var a in audioDictionary) { AL.DeleteBuffer(a.Value); } audioDictionary.Clear(); foreach (var f in frameBufferDictionary) { f.Value.CleanUp(); } frameBufferDictionary.Clear(); materialDictionary.Clear(); }
public void Shutdown() { if (s_audio.noSound) { return; } AL.DeleteBuffer(buffer); }
private void CleanupSource() { if (alSource > -1) { AL.DeleteBuffer(alBuffer); AL.DeleteSource(alSource); } }
public void Dispose() { if (!disposed) { al.DeleteBuffer(bufferIndex); disposed = true; } }
public void Stop() { SetVolume(0); AL.SourceStop(source); AL.Source(source, ALSourcei.Buffer, 0); AL.DeleteSource(source); AL.DeleteBuffer(buffer); }
public static void Close() { foreach (int myBuffer in audioDictionary.Values) { AL.DeleteBuffer(myBuffer); } audioDictionary.Clear(); }