SplitterDestinationInParameter.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 Ryujinx.Common.Utilities;
  18. using System;
  19. using System.Runtime.InteropServices;
  20. namespace Ryujinx.Audio.Renderer.Parameter
  21. {
  22. /// <summary>
  23. /// Input header for a splitter destination update.
  24. /// </summary>
  25. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  26. public struct SplitterDestinationInParameter
  27. {
  28. /// <summary>
  29. /// Magic of the input header.
  30. /// </summary>
  31. public uint Magic;
  32. /// <summary>
  33. /// Target splitter destination data id.
  34. /// </summary>
  35. public int Id;
  36. /// <summary>
  37. /// Mix buffer volumes storage.
  38. /// </summary>
  39. private MixArray _mixBufferVolume;
  40. /// <summary>
  41. /// The mix to output the result of the splitter.
  42. /// </summary>
  43. public int DestinationId;
  44. /// <summary>
  45. /// Set to true if in use.
  46. /// </summary>
  47. [MarshalAs(UnmanagedType.I1)]
  48. public bool IsUsed;
  49. /// <summary>
  50. /// Reserved/padding.
  51. /// </summary>
  52. private unsafe fixed byte _reserved[3];
  53. [StructLayout(LayoutKind.Sequential, Size = 4 * RendererConstants.MixBufferCountMax, Pack = 1)]
  54. private struct MixArray { }
  55. /// <summary>
  56. /// Mix buffer volumes.
  57. /// </summary>
  58. /// <remarks>Used when a splitter id is specified in the mix.</remarks>
  59. public Span<float> MixBufferVolume => SpanHelpers.AsSpan<MixArray, float>(ref _mixBufferVolume);
  60. /// <summary>
  61. /// The expected constant of any input header.
  62. /// </summary>
  63. private const uint ValidMagic = 0x44444E53;
  64. /// <summary>
  65. /// Check if the magic is valid.
  66. /// </summary>
  67. /// <returns>Returns true if the magic is valid.</returns>
  68. public bool IsMagicValid()
  69. {
  70. return Magic == ValidMagic;
  71. }
  72. }
  73. }