AvioBuffer.cs 787 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. namespace Bmp.Core.FFMpeg.CsCorePorts.FFMpegWrap;
  2. internal sealed class AvioBuffer : IDisposable
  3. {
  4. public int BufferSize { get; private set; }
  5. public nint Buffer { get; private set; }
  6. public bool SuppressAvFree { get; set; }
  7. public AvioBuffer()
  8. : this(0x1000)
  9. {
  10. }
  11. public AvioBuffer(int bufferSize)
  12. {
  13. if (bufferSize <= 0)
  14. throw new ArgumentOutOfRangeException("bufferSize");
  15. BufferSize = bufferSize;
  16. Buffer = FfmpegCalls.AvMalloc(bufferSize);
  17. SuppressAvFree = false;
  18. }
  19. public void Dispose()
  20. {
  21. GC.SuppressFinalize(this);
  22. if (SuppressAvFree != true)
  23. {
  24. FfmpegCalls.AvFree(Buffer);
  25. }
  26. }
  27. ~AvioBuffer()
  28. {
  29. Dispose();
  30. }
  31. }