UpsamplerState.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. //
  2. // Copyright (c) 2019-2021 Ryujinx
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Lesser General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Lesser General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Lesser General Public License
  15. // along with this program. If not, see <https://www.gnu.org/licenses/>.
  16. //
  17. using System;
  18. namespace Ryujinx.Audio.Renderer.Server.Upsampler
  19. {
  20. /// <summary>
  21. /// Server state for a upsampling.
  22. /// </summary>
  23. public class UpsamplerState
  24. {
  25. /// <summary>
  26. /// The output buffer containing the target samples.
  27. /// </summary>
  28. public Memory<float> OutputBuffer { get; }
  29. /// <summary>
  30. /// The target sample count.
  31. /// </summary>
  32. public uint SampleCount { get; }
  33. /// <summary>
  34. /// The index of the <see cref="UpsamplerState"/>. (used to free it)
  35. /// </summary>
  36. private int _index;
  37. /// <summary>
  38. /// The <see cref="UpsamplerManager"/>.
  39. /// </summary>
  40. private UpsamplerManager _manager;
  41. /// <summary>
  42. /// The source sample count.
  43. /// </summary>
  44. public uint SourceSampleCount;
  45. /// <summary>
  46. /// The input buffer indices of the buffers holding the samples that need upsampling.
  47. /// </summary>
  48. public ushort[] InputBufferIndices;
  49. /// <summary>
  50. /// Create a new <see cref="UpsamplerState"/>.
  51. /// </summary>
  52. /// <param name="manager">The upsampler manager.</param>
  53. /// <param name="index">The index of the <see cref="UpsamplerState"/>. (used to free it)</param>
  54. /// <param name="outputBuffer">The output buffer used to contain the target samples.</param>
  55. /// <param name="sampleCount">The target sample count.</param>
  56. public UpsamplerState(UpsamplerManager manager, int index, Memory<float> outputBuffer, uint sampleCount)
  57. {
  58. _manager = manager;
  59. _index = index;
  60. OutputBuffer = outputBuffer;
  61. SampleCount = sampleCount;
  62. }
  63. /// <summary>
  64. /// Release the <see cref="UpsamplerState"/>.
  65. /// </summary>
  66. public void Release()
  67. {
  68. _manager.Free(_index);
  69. }
  70. }
  71. }