//
// Copyright (c) 2019-2020 Ryujinx
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see .
//
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
{
///
/// Base class used for server information of a sink.
///
public class BaseSink
{
///
/// The type of this .
///
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 .
///
public BaseSink()
{
CleanUp();
}
///
/// Clean up the internal state of the .
///
public virtual void CleanUp()
{
Type = TargetSinkType;
IsUsed = false;
ShouldSkip = false;
}
///
/// The target handled by this .
///
public virtual SinkType TargetSinkType => SinkType.Invalid;
///
/// Check if the sent by the user match the internal .
///
/// The user parameter.
/// Return true, if the sent by the user match the internal .
public bool IsTypeValid(ref SinkInParameter parameter)
{
return parameter.Type == TargetSinkType;
}
///
/// Update the state during command generation.
///
public virtual void UpdateForCommandGeneration()
{
Debug.Assert(Type == TargetSinkType);
}
///
/// Update the internal common parameters from user parameter.
///
/// The 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.
///
/// The possible that was generated.
/// The user parameter.
/// The user output status.
/// The mapper to use.
public virtual void Update(out ErrorInfo errorInfo, ref SinkInParameter parameter, ref SinkOutStatus outStatus, PoolMapper mapper)
{
Debug.Assert(IsTypeValid(ref parameter));
errorInfo = new ErrorInfo();
}
}
}