[Ryujinx.Audio] Address dotnet-format issues (#5362)
* 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>
This commit is contained in:
@ -19,7 +19,6 @@ using System;
|
||||
using System.Buffers;
|
||||
using System.Diagnostics;
|
||||
using System.Threading;
|
||||
|
||||
using CpuAddress = System.UInt64;
|
||||
|
||||
namespace Ryujinx.Audio.Renderer.Server
|
||||
@ -30,19 +29,21 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
private AudioRendererRenderingDevice _renderingDevice;
|
||||
private AudioRendererExecutionMode _executionMode;
|
||||
private IWritableEvent _systemEvent;
|
||||
private readonly IWritableEvent _systemEvent;
|
||||
private MemoryPoolState _dspMemoryPoolState;
|
||||
private VoiceContext _voiceContext;
|
||||
private MixContext _mixContext;
|
||||
private SinkContext _sinkContext;
|
||||
private SplitterContext _splitterContext;
|
||||
private EffectContext _effectContext;
|
||||
private readonly VoiceContext _voiceContext;
|
||||
private readonly MixContext _mixContext;
|
||||
private readonly SinkContext _sinkContext;
|
||||
private readonly SplitterContext _splitterContext;
|
||||
private readonly EffectContext _effectContext;
|
||||
private PerformanceManager _performanceManager;
|
||||
private UpsamplerManager _upsamplerManager;
|
||||
private bool _isActive;
|
||||
private BehaviourContext _behaviourContext;
|
||||
#pragma warning disable IDE0052 // Remove unread private member
|
||||
private ulong _totalElapsedTicksUpdating;
|
||||
private ulong _totalElapsedTicks;
|
||||
#pragma warning restore IDE0052
|
||||
private int _sessionId;
|
||||
private Memory<MemoryPoolState> _memoryPools;
|
||||
|
||||
@ -75,7 +76,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
private ulong _elapsedFrameCount;
|
||||
private ulong _renderingStartTick;
|
||||
|
||||
private AudioRendererManager _manager;
|
||||
private readonly AudioRendererManager _manager;
|
||||
|
||||
private int _disposeState;
|
||||
|
||||
@ -143,12 +144,12 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
WorkBufferAllocator workBufferAllocator;
|
||||
|
||||
workBufferMemory.Span.Fill(0);
|
||||
workBufferMemory.Span.Clear();
|
||||
_workBufferMemoryPin = workBufferMemory.Pin();
|
||||
|
||||
workBufferAllocator = new WorkBufferAllocator(workBufferMemory);
|
||||
|
||||
PoolMapper poolMapper = new PoolMapper(processHandle, false);
|
||||
PoolMapper poolMapper = new(processHandle, false);
|
||||
poolMapper.InitializeSystemPool(ref _dspMemoryPoolState, workBuffer, workBufferSize);
|
||||
|
||||
_mixBuffer = workBufferAllocator.Allocate<float>(_sampleCount * (_voiceChannelCountMax + _mixBufferCount), 0x10);
|
||||
@ -244,9 +245,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
foreach (ref MixState mix in mixes.Span)
|
||||
{
|
||||
mix = new MixState(effectProcessingOrderArray.Slice(0, (int)parameter.EffectCount), ref _behaviourContext);
|
||||
mix = new MixState(effectProcessingOrderArray[..(int)parameter.EffectCount], ref _behaviourContext);
|
||||
|
||||
effectProcessingOrderArray = effectProcessingOrderArray.Slice((int)parameter.EffectCount);
|
||||
effectProcessingOrderArray = effectProcessingOrderArray[(int)parameter.EffectCount..];
|
||||
}
|
||||
}
|
||||
|
||||
@ -341,26 +342,15 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
_elapsedFrameCount = 0;
|
||||
_voiceDropParameter = 1.0f;
|
||||
|
||||
switch (_behaviourContext.GetCommandProcessingTimeEstimatorVersion())
|
||||
_commandProcessingTimeEstimator = _behaviourContext.GetCommandProcessingTimeEstimatorVersion() switch
|
||||
{
|
||||
case 1:
|
||||
_commandProcessingTimeEstimator = new CommandProcessingTimeEstimatorVersion1(_sampleCount, _mixBufferCount);
|
||||
break;
|
||||
case 2:
|
||||
_commandProcessingTimeEstimator = new CommandProcessingTimeEstimatorVersion2(_sampleCount, _mixBufferCount);
|
||||
break;
|
||||
case 3:
|
||||
_commandProcessingTimeEstimator = new CommandProcessingTimeEstimatorVersion3(_sampleCount, _mixBufferCount);
|
||||
break;
|
||||
case 4:
|
||||
_commandProcessingTimeEstimator = new CommandProcessingTimeEstimatorVersion4(_sampleCount, _mixBufferCount);
|
||||
break;
|
||||
case 5:
|
||||
_commandProcessingTimeEstimator = new CommandProcessingTimeEstimatorVersion5(_sampleCount, _mixBufferCount);
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException($"Unsupported processing time estimator version {_behaviourContext.GetCommandProcessingTimeEstimatorVersion()}.");
|
||||
}
|
||||
1 => new CommandProcessingTimeEstimatorVersion1(_sampleCount, _mixBufferCount),
|
||||
2 => new CommandProcessingTimeEstimatorVersion2(_sampleCount, _mixBufferCount),
|
||||
3 => new CommandProcessingTimeEstimatorVersion3(_sampleCount, _mixBufferCount),
|
||||
4 => new CommandProcessingTimeEstimatorVersion4(_sampleCount, _mixBufferCount),
|
||||
5 => new CommandProcessingTimeEstimatorVersion5(_sampleCount, _mixBufferCount),
|
||||
_ => throw new NotImplementedException($"Unsupported processing time estimator version {_behaviourContext.GetCommandProcessingTimeEstimatorVersion()}."),
|
||||
};
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
@ -402,9 +392,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
{
|
||||
ulong updateStartTicks = GetSystemTicks();
|
||||
|
||||
output.Span.Fill(0);
|
||||
output.Span.Clear();
|
||||
|
||||
StateUpdater stateUpdater = new StateUpdater(input, output, _processHandle, _behaviourContext);
|
||||
StateUpdater stateUpdater = new(input, output, _processHandle, _behaviourContext);
|
||||
|
||||
ResultCode result;
|
||||
|
||||
@ -609,9 +599,9 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
_renderingStartTick = 0;
|
||||
}
|
||||
|
||||
CommandBuffer commandBuffer = new CommandBuffer(commandList, _commandProcessingTimeEstimator);
|
||||
CommandBuffer commandBuffer = new(commandList, _commandProcessingTimeEstimator);
|
||||
|
||||
CommandGenerator commandGenerator = new CommandGenerator(commandBuffer, GetContext(), _voiceContext, _mixContext, _effectContext, _sinkContext, _splitterContext, _performanceManager);
|
||||
CommandGenerator commandGenerator = new(commandBuffer, GetContext(), _voiceContext, _mixContext, _effectContext, _sinkContext, _splitterContext, _performanceManager);
|
||||
|
||||
_voiceContext.Sort();
|
||||
commandGenerator.GenerateVoices();
|
||||
@ -731,7 +721,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
DepopBuffer = _depopBuffer,
|
||||
MixBufferCount = GetMixBufferCount(),
|
||||
SessionId = _sessionId,
|
||||
UpsamplerManager = _upsamplerManager
|
||||
UpsamplerManager = _upsamplerManager,
|
||||
};
|
||||
}
|
||||
|
||||
@ -742,7 +732,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public static ulong GetWorkBufferSize(ref AudioRendererConfiguration parameter)
|
||||
{
|
||||
BehaviourContext behaviourContext = new BehaviourContext();
|
||||
BehaviourContext behaviourContext = new();
|
||||
|
||||
behaviourContext.SetUserRevision(parameter.Revision);
|
||||
|
||||
@ -813,6 +803,8 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
GC.SuppressFinalize(this);
|
||||
|
||||
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
|
||||
{
|
||||
Dispose(true);
|
||||
@ -828,7 +820,7 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
Stop();
|
||||
}
|
||||
|
||||
PoolMapper mapper = new PoolMapper(_processHandle, false);
|
||||
PoolMapper mapper = new(_processHandle, false);
|
||||
mapper.Unmap(ref _dspMemoryPoolState);
|
||||
|
||||
PoolMapper.ClearUsageState(_memoryPools);
|
||||
@ -876,4 +868,4 @@ namespace Ryujinx.Audio.Renderer.Server
|
||||
return ResultCode.UnsupportedOperation;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user