EffectInParameterVersion1.cs 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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.Audio.Renderer.Common;
  18. using Ryujinx.Common.Utilities;
  19. using System;
  20. using System.Runtime.InteropServices;
  21. namespace Ryujinx.Audio.Renderer.Parameter
  22. {
  23. /// <summary>
  24. /// Input information for an effect version 1.
  25. /// </summary>
  26. [StructLayout(LayoutKind.Sequential, Pack = 1)]
  27. public struct EffectInParameterVersion1 : IEffectInParameter
  28. {
  29. /// <summary>
  30. /// Type of the effect.
  31. /// </summary>
  32. public EffectType Type;
  33. /// <summary>
  34. /// Set to true if the effect is new.
  35. /// </summary>
  36. [MarshalAs(UnmanagedType.I1)]
  37. public bool IsNew;
  38. /// <summary>
  39. /// Set to true if the effect must be active.
  40. /// </summary>
  41. [MarshalAs(UnmanagedType.I1)]
  42. public bool IsEnabled;
  43. /// <summary>
  44. /// Reserved/padding.
  45. /// </summary>
  46. private byte _reserved1;
  47. /// <summary>
  48. /// The target mix id of the effect.
  49. /// </summary>
  50. public int MixId;
  51. /// <summary>
  52. /// Address of the processing workbuffer.
  53. /// </summary>
  54. /// <remarks>This is additional data that could be required by the effect processing.</remarks>
  55. public ulong BufferBase;
  56. /// <summary>
  57. /// Size of the processing workbuffer.
  58. /// </summary>
  59. /// <remarks>This is additional data that could be required by the effect processing.</remarks>
  60. public ulong BufferSize;
  61. /// <summary>
  62. /// Position of the effect while processing effects.
  63. /// </summary>
  64. public uint ProcessingOrder;
  65. /// <summary>
  66. /// Reserved/padding.
  67. /// </summary>
  68. private uint _reserved2;
  69. /// <summary>
  70. /// Specific data storage.
  71. /// </summary>
  72. private SpecificDataStruct _specificDataStart;
  73. [StructLayout(LayoutKind.Sequential, Size = 0xA0, Pack = 1)]
  74. private struct SpecificDataStruct { }
  75. public Span<byte> SpecificData => SpanHelpers.AsSpan<SpecificDataStruct, byte>(ref _specificDataStart);
  76. EffectType IEffectInParameter.Type => Type;
  77. bool IEffectInParameter.IsNew => IsNew;
  78. bool IEffectInParameter.IsEnabled => IsEnabled;
  79. int IEffectInParameter.MixId => MixId;
  80. ulong IEffectInParameter.BufferBase => BufferBase;
  81. ulong IEffectInParameter.BufferSize => BufferSize;
  82. uint IEffectInParameter.ProcessingOrder => ProcessingOrder;
  83. /// <summary>
  84. /// Check if the given channel count is valid.
  85. /// </summary>
  86. /// <param name="channelCount">The channel count to check</param>
  87. /// <returns>Returns true if the channel count is valid.</returns>
  88. public static bool IsChannelCountValid(int channelCount)
  89. {
  90. return channelCount == 1 || channelCount == 2 || channelCount == 4 || channelCount == 6;
  91. }
  92. }
  93. }