mirror of
https://github.com/Ryubing/Ryujinx.git
synced 2025-11-29 01:12:25 -05:00
* dotnet format style --severity info Some changes were manually reverted. * dotnet format analyzers --serverity info Some changes have been minimally adapted. * Restore a few unused methods and variables * Silence dotnet format IDE0060 warnings * Silence dotnet format IDE0052 warnings * Address dotnet format CA1816 warnings * Address or silence dotnet format CA2208 warnings * Address or silence dotnet format CA2211 warnings * Address review comments * Address most dotnet format whitespace warnings * Apply dotnet format whitespace formatting A few of them have been manually reverted and the corresponding warning was silenced * Format if-blocks correctly * Run dotnet format whitespace after rebase * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * Add comments to disabled warnings * Remove a few unused parameters * Simplify properties and array initialization, Use const when possible, Remove trailing commas * Start working on disabled warnings * Fix and silence a few dotnet-format warnings again * Address IDE0251 warnings * Silence IDE0060 in .editorconfig * Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas" This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e. * dotnet format whitespace after rebase * Fix naming rule violations, remove redundant code and fix build issues * Apply suggestions from code review Co-authored-by: Ac_K <Acoustik666@gmail.com> * Add trailing commas * Apply suggestions from code review Co-authored-by: Ac_K <Acoustik666@gmail.com> * Address review feedback --------- Co-authored-by: Ac_K <Acoustik666@gmail.com>
110 lines
3.6 KiB
C#
110 lines
3.6 KiB
C#
using Ryujinx.Audio.Renderer.Common;
|
|
using Ryujinx.Audio.Renderer.Parameter;
|
|
using Ryujinx.Audio.Renderer.Parameter.Sink;
|
|
using Ryujinx.Audio.Renderer.Server.MemoryPool;
|
|
using System.Diagnostics;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace Ryujinx.Audio.Renderer.Server.Sink
|
|
{
|
|
/// <summary>
|
|
/// Server information for a circular buffer sink.
|
|
/// </summary>
|
|
public class CircularBufferSink : BaseSink
|
|
{
|
|
/// <summary>
|
|
/// The circular buffer parameter.
|
|
/// </summary>
|
|
public CircularBufferParameter Parameter;
|
|
|
|
/// <summary>
|
|
/// The last written data offset on the circular buffer.
|
|
/// </summary>
|
|
private uint _lastWrittenOffset;
|
|
|
|
/// <summary>
|
|
/// THe previous written offset of the circular buffer.
|
|
/// </summary>
|
|
private uint _oldWrittenOffset;
|
|
|
|
/// <summary>
|
|
/// The current offset to write data on the circular buffer.
|
|
/// </summary>
|
|
public uint CurrentWriteOffset { get; private set; }
|
|
|
|
/// <summary>
|
|
/// The <see cref="AddressInfo"/> of the circular buffer.
|
|
/// </summary>
|
|
public AddressInfo CircularBufferAddressInfo;
|
|
|
|
public CircularBufferSink()
|
|
{
|
|
CircularBufferAddressInfo = AddressInfo.Create();
|
|
}
|
|
|
|
public override SinkType TargetSinkType => SinkType.CircularBuffer;
|
|
|
|
public override void Update(out BehaviourParameter.ErrorInfo errorInfo, ref SinkInParameter parameter, ref SinkOutStatus outStatus, PoolMapper mapper)
|
|
{
|
|
errorInfo = new BehaviourParameter.ErrorInfo();
|
|
outStatus = new SinkOutStatus();
|
|
|
|
Debug.Assert(IsTypeValid(ref parameter));
|
|
|
|
ref CircularBufferParameter inputDeviceParameter = ref MemoryMarshal.Cast<byte, CircularBufferParameter>(parameter.SpecificData)[0];
|
|
|
|
if (parameter.IsUsed != IsUsed || ShouldSkip)
|
|
{
|
|
UpdateStandardParameter(ref parameter);
|
|
|
|
if (parameter.IsUsed)
|
|
{
|
|
Debug.Assert(CircularBufferAddressInfo.CpuAddress == 0);
|
|
Debug.Assert(CircularBufferAddressInfo.GetReference(false) == 0);
|
|
|
|
ShouldSkip = !mapper.TryAttachBuffer(out errorInfo, ref CircularBufferAddressInfo, inputDeviceParameter.BufferAddress, inputDeviceParameter.BufferSize);
|
|
}
|
|
else
|
|
{
|
|
Debug.Assert(CircularBufferAddressInfo.CpuAddress != 0);
|
|
Debug.Assert(CircularBufferAddressInfo.GetReference(false) != 0);
|
|
}
|
|
|
|
Parameter = inputDeviceParameter;
|
|
}
|
|
|
|
outStatus.LastWrittenOffset = _lastWrittenOffset;
|
|
}
|
|
|
|
public override void UpdateForCommandGeneration()
|
|
{
|
|
Debug.Assert(Type == TargetSinkType);
|
|
|
|
if (IsUsed)
|
|
{
|
|
uint frameSize = Constants.TargetSampleSize * Parameter.SampleCount * Parameter.InputCount;
|
|
|
|
_lastWrittenOffset = _oldWrittenOffset;
|
|
|
|
_oldWrittenOffset = CurrentWriteOffset;
|
|
|
|
CurrentWriteOffset += frameSize;
|
|
|
|
if (Parameter.BufferSize > 0)
|
|
{
|
|
CurrentWriteOffset %= Parameter.BufferSize;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void CleanUp()
|
|
{
|
|
CircularBufferAddressInfo = AddressInfo.Create();
|
|
_lastWrittenOffset = 0;
|
|
_oldWrittenOffset = 0;
|
|
CurrentWriteOffset = 0;
|
|
base.CleanUp();
|
|
}
|
|
}
|
|
}
|