using Ryujinx.Audio.Renderer.Common;
using Ryujinx.Audio.Renderer.Parameter;
using Ryujinx.Audio.Renderer.Server.MemoryPool;
using System.Diagnostics;
using static Ryujinx.Audio.Renderer.Common.BehaviourParameter;
namespace Ryujinx.Audio.Renderer.Server.Sink
{
/// <summary>
/// Base class used for server information of a sink.
/// </summary>
public class BaseSink
/// The type of this <see cref="BaseSink"/>.
public SinkType Type;
/// Set to true if the sink is used.
public bool IsUsed;
/// Set to true if the sink need to be skipped because of invalid state.
public bool ShouldSkip;
/// The node id of the sink.
public int NodeId;
/// Create a new <see cref="BaseSink"/>.
public BaseSink()
CleanUp();
}
/// Clean up the internal state of the <see cref="BaseSink"/>.
public virtual void CleanUp()
Type = TargetSinkType;
IsUsed = false;
ShouldSkip = false;
/// The target <see cref="SinkType"/> handled by this <see cref="BaseSink"/>.
public virtual SinkType TargetSinkType => SinkType.Invalid;
/// Check if the <see cref="SinkType"/> sent by the user match the internal <see cref="SinkType"/>.
/// <param name="parameter">The user parameter.</param>
/// <returns>Return true, if the <see cref="SinkType"/> sent by the user match the internal <see cref="SinkType"/>.</returns>
public bool IsTypeValid(ref SinkInParameter parameter)
return parameter.Type == TargetSinkType;
/// Update the <see cref="BaseSink"/> state during command generation.
public virtual void UpdateForCommandGeneration()
Debug.Assert(Type == TargetSinkType);
/// Update the internal common parameters from user parameter.
protected void UpdateStandardParameter(ref SinkInParameter parameter)
if (IsUsed != parameter.IsUsed)
IsUsed = parameter.IsUsed;
NodeId = parameter.NodeId;
/// Update the internal state from user parameter.
/// <param name="errorInfo">The possible <see cref="ErrorInfo"/> that was generated.</param>
/// <param name="outStatus">The user output status.</param>
/// <param name="mapper">The mapper to use.</param>
public virtual void Update(out ErrorInfo errorInfo, ref SinkInParameter parameter, ref SinkOutStatus outStatus, PoolMapper mapper)
Debug.Assert(IsTypeValid(ref parameter));
errorInfo = new ErrorInfo();