UpsamplerState.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. /// State of each input buffer index kept across invocations of the upsampler.
  35. /// </summary>
  36. public UpsamplerBufferState[] BufferStates;
  37. /// <summary>
  38. /// Create a new <see cref="UpsamplerState"/>.
  39. /// </summary>
  40. /// <param name="manager">The upsampler manager.</param>
  41. /// <param name="index">The index of the <see cref="UpsamplerState"/>. (used to free it)</param>
  42. /// <param name="outputBuffer">The output buffer used to contain the target samples.</param>
  43. /// <param name="sampleCount">The target sample count.</param>
  44. public UpsamplerState(UpsamplerManager manager, int index, Memory<float> outputBuffer, uint sampleCount)
  45. {
  46. _manager = manager;
  47. _index = index;
  48. OutputBuffer = outputBuffer;
  49. SampleCount = sampleCount;
  50. }
  51. /// <summary>
  52. /// Release the <see cref="UpsamplerState"/>.
  53. /// </summary>
  54. public void Release()
  55. {
  56. _manager.Free(_index);
  57. }
  58. }
  59. }