UpsamplerState.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. namespace Ryujinx.Audio.Renderer.Server.Upsampler
  3. {
  4. /// <summary>
  5. /// Server state for a upsampling.
  6. /// </summary>
  7. public class UpsamplerState
  8. {
  9. /// <summary>
  10. /// The output buffer containing the target samples.
  11. /// </summary>
  12. public Memory<float> OutputBuffer { get; }
  13. /// <summary>
  14. /// The target sample count.
  15. /// </summary>
  16. public uint SampleCount { get; }
  17. /// <summary>
  18. /// The index of the <see cref="UpsamplerState"/>. (used to free it)
  19. /// </summary>
  20. private int _index;
  21. /// <summary>
  22. /// The <see cref="UpsamplerManager"/>.
  23. /// </summary>
  24. private UpsamplerManager _manager;
  25. /// <summary>
  26. /// The source sample count.
  27. /// </summary>
  28. public uint SourceSampleCount;
  29. /// <summary>
  30. /// The input buffer indices of the buffers holding the samples that need upsampling.
  31. /// </summary>
  32. public ushort[] InputBufferIndices;
  33. /// <summary>
  34. /// Create a new <see cref="UpsamplerState"/>.
  35. /// </summary>
  36. /// <param name="manager">The upsampler manager.</param>
  37. /// <param name="index">The index of the <see cref="UpsamplerState"/>. (used to free it)</param>
  38. /// <param name="outputBuffer">The output buffer used to contain the target samples.</param>
  39. /// <param name="sampleCount">The target sample count.</param>
  40. public UpsamplerState(UpsamplerManager manager, int index, Memory<float> outputBuffer, uint sampleCount)
  41. {
  42. _manager = manager;
  43. _index = index;
  44. OutputBuffer = outputBuffer;
  45. SampleCount = sampleCount;
  46. }
  47. /// <summary>
  48. /// Release the <see cref="UpsamplerState"/>.
  49. /// </summary>
  50. public void Release()
  51. {
  52. _manager.Free(_index);
  53. }
  54. }
  55. }