WaveBuffer.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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.Runtime.InteropServices;
  18. using DspAddr = System.UInt64;
  19. namespace Ryujinx.Audio.Renderer.Common
  20. {
  21. /// <summary>
  22. /// A wavebuffer used for data source commands.
  23. /// </summary>
  24. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  25. public struct WaveBuffer
  26. {
  27. /// <summary>
  28. /// The DSP address of the sample data of the wavebuffer.
  29. /// </summary>
  30. public DspAddr Buffer;
  31. /// <summary>
  32. /// The DSP address of the context of the wavebuffer.
  33. /// </summary>
  34. /// <remarks>Only used by <see cref="SampleFormat.Adpcm"/>.</remarks>
  35. public DspAddr Context;
  36. /// <summary>
  37. /// The size of the sample buffer data.
  38. /// </summary>
  39. public uint BufferSize;
  40. /// <summary>
  41. /// The size of the context buffer.
  42. /// </summary>
  43. public uint ContextSize;
  44. /// <summary>
  45. /// First sample to play on the wavebuffer.
  46. /// </summary>
  47. public uint StartSampleOffset;
  48. /// <summary>
  49. /// Last sample to play on the wavebuffer.
  50. /// </summary>
  51. public uint EndSampleOffset;
  52. /// <summary>
  53. /// First sample to play when looping the wavebuffer.
  54. /// </summary>
  55. /// <remarks>
  56. /// If <see cref="LoopStartSampleOffset"/> or <see cref="LoopEndSampleOffset"/> is equal to zero,, it will default to <see cref="StartSampleOffset"/> and <see cref="EndSampleOffset"/>.
  57. /// </remarks>
  58. public uint LoopStartSampleOffset;
  59. /// <summary>
  60. /// Last sample to play when looping the wavebuffer.
  61. /// </summary>
  62. /// <remarks>
  63. /// If <see cref="LoopStartSampleOffset"/> or <see cref="LoopEndSampleOffset"/> is equal to zero, it will default to <see cref="StartSampleOffset"/> and <see cref="EndSampleOffset"/>.
  64. /// </remarks>
  65. public uint LoopEndSampleOffset;
  66. /// <summary>
  67. /// The max loop count.
  68. /// </summary>
  69. public int LoopCount;
  70. /// <summary>
  71. /// Set to true if the wavebuffer is looping.
  72. /// </summary>
  73. [MarshalAs(UnmanagedType.I1)]
  74. public bool Looping;
  75. /// <summary>
  76. /// Set to true if the wavebuffer is the end of stream.
  77. /// </summary>
  78. [MarshalAs(UnmanagedType.I1)]
  79. public bool IsEndOfStream;
  80. /// <summary>
  81. /// Padding/Reserved.
  82. /// </summary>
  83. private ushort _padding;
  84. }
  85. }