namespace AudioCore.Impl; public class AudioBuffer : IDisposable { private readonly GenericBufferPool _owner; private bool _disposed; public T[] Samples { get; } public int Length { get; set; } // number of valid samples internal AudioBuffer(T[] samples, int capacity, GenericBufferPool owner) { Samples = samples; Length = capacity; _owner = owner; } public Span Span => _disposed ? default : Samples.AsSpan(0, Length); public void Dispose() { if (_disposed) return; _owner.Return(Samples); _disposed = true; } }