[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:
TSRBerry 2023-07-02 01:27:18 +02:00 committed by GitHub
parent 0684b00b3c
commit 515fc32b21
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
207 changed files with 1354 additions and 1670 deletions

View file

@ -1,5 +1,6 @@
using Ryujinx.Audio.Common;
using Ryujinx.Audio.Renderer.Common;
using Ryujinx.Audio.Renderer.Dsp.State;
using Ryujinx.Audio.Renderer.Parameter;
using Ryujinx.Audio.Renderer.Server.MemoryPool;
using Ryujinx.Common.Memory;
@ -9,6 +10,7 @@ using System.Diagnostics;
using System.Runtime.InteropServices;
using static Ryujinx.Audio.Renderer.Common.BehaviourParameter;
using static Ryujinx.Audio.Renderer.Parameter.VoiceInParameter;
using PlayState = Ryujinx.Audio.Renderer.Server.Types.PlayState;
namespace Ryujinx.Audio.Renderer.Server.Voice
{
@ -65,12 +67,12 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
/// <summary>
/// The current voice <see cref="Types.PlayState"/>.
/// </summary>
public Types.PlayState PlayState;
public PlayState PlayState;
/// <summary>
/// The previous voice <see cref="Types.PlayState"/>.
/// </summary>
public Types.PlayState PreviousPlayState;
public PlayState PreviousPlayState;
/// <summary>
/// The priority of the voice.
@ -192,7 +194,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
DataSourceStateUnmapped = false;
BufferInfoUnmapped = false;
FlushWaveBufferCount = 0;
PlayState = Types.PlayState.Stopped;
PlayState = PlayState.Stopped;
Priority = Constants.VoiceLowestPriority;
Id = 0;
NodeId = 0;
@ -202,7 +204,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
Pitch = 0.0f;
Volume = 0.0f;
PreviousVolume = 0.0f;
BiquadFilters.AsSpan().Fill(new BiquadFilterParameter());
BiquadFilters.AsSpan().Clear();
WaveBuffersCount = 0;
WaveBuffersIndex = 0;
MixId = Constants.UnusedMixId;
@ -233,7 +235,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
/// Check if the voice needs to be skipped.
/// </summary>
/// <returns>Returns true if the voice needs to be skipped.</returns>
public bool ShouldSkip()
public readonly bool ShouldSkip()
{
return !InUse || WaveBuffersCount == 0 || DataSourceStateUnmapped || BufferInfoUnmapped || VoiceDropFlag;
}
@ -242,7 +244,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
/// Return true if the mix has any destinations.
/// </summary>
/// <returns>True if the mix has any destinations.</returns>
public bool HasAnyDestination()
public readonly bool HasAnyDestination()
{
return MixId != Constants.UnusedMixId || SplitterId != Constants.UnusedSplitterId;
}
@ -252,7 +254,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
/// </summary>
/// <param name="parameter">The user parameter.</param>
/// <returns>Return true, if the server voice information needs to be updated.</returns>
private bool ShouldUpdateParameters(ref VoiceInParameter parameter)
private readonly bool ShouldUpdateParameters(ref VoiceInParameter parameter)
{
if (DataSourceStateAddressInfo.CpuAddress == parameter.DataSourceStateAddress)
{
@ -338,31 +340,31 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
/// Update the internal play state from user play state.
/// </summary>
/// <param name="userPlayState">The target user play state.</param>
public void UpdatePlayState(PlayState userPlayState)
public void UpdatePlayState(Common.PlayState userPlayState)
{
Types.PlayState oldServerPlayState = PlayState;
PlayState oldServerPlayState = PlayState;
PreviousPlayState = oldServerPlayState;
Types.PlayState newServerPlayState;
PlayState newServerPlayState;
switch (userPlayState)
{
case Common.PlayState.Start:
newServerPlayState = Types.PlayState.Started;
newServerPlayState = PlayState.Started;
break;
case Common.PlayState.Stop:
if (oldServerPlayState == Types.PlayState.Stopped)
if (oldServerPlayState == PlayState.Stopped)
{
return;
}
newServerPlayState = Types.PlayState.Stopping;
newServerPlayState = PlayState.Stopping;
break;
case Common.PlayState.Pause:
newServerPlayState = Types.PlayState.Paused;
newServerPlayState = PlayState.Paused;
break;
default:
@ -434,7 +436,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
for (int i = 0; i < parameter.ChannelCount; i++)
{
voiceUpdateStates[i].Span[0].IsWaveBufferValid.Fill(false);
voiceUpdateStates[i].Span[0].IsWaveBufferValid.Clear();
}
}
@ -530,7 +532,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
Memory<VoiceUpdateState> dspSharedState = context.GetUpdateStateForDsp(channelResourceId);
MemoryMarshal.Cast<VoiceUpdateState, byte>(dspSharedState.Span).Fill(0);
MemoryMarshal.Cast<VoiceUpdateState, byte>(dspSharedState.Span).Clear();
voiceChannelResource.UpdateState();
}
@ -579,7 +581,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
switch (PlayState)
{
case Types.PlayState.Started:
case PlayState.Started:
for (int i = 0; i < WaveBuffers.Length; i++)
{
ref WaveBuffer wavebuffer = ref WaveBuffers[i];
@ -611,7 +613,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
return false;
case Types.PlayState.Stopping:
case PlayState.Stopping:
for (int i = 0; i < WaveBuffers.Length; i++)
{
ref WaveBuffer wavebuffer = ref WaveBuffers[i];
@ -638,18 +640,18 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
voiceUpdateState.Offset = 0;
voiceUpdateState.PlayedSampleCount = 0;
voiceUpdateState.Pitch.AsSpan().Fill(0);
voiceUpdateState.Pitch.AsSpan().Clear();
voiceUpdateState.Fraction = 0;
voiceUpdateState.LoopContext = new Dsp.State.AdpcmLoopContext();
voiceUpdateState.LoopContext = new AdpcmLoopContext();
}
PlayState = Types.PlayState.Stopped;
WasPlaying = PreviousPlayState == Types.PlayState.Started;
PlayState = PlayState.Stopped;
WasPlaying = PreviousPlayState == PlayState.Started;
return WasPlaying;
case Types.PlayState.Stopped:
case Types.PlayState.Paused:
case PlayState.Stopped:
case PlayState.Paused:
foreach (ref WaveBuffer wavebuffer in WaveBuffers.AsSpan())
{
wavebuffer.BufferAddressInfo.GetReference(true);
@ -664,7 +666,7 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
}
}
WasPlaying = PreviousPlayState == Types.PlayState.Started;
WasPlaying = PreviousPlayState == PlayState.Started;
return WasPlaying;
default:
@ -696,4 +698,4 @@ namespace Ryujinx.Audio.Renderer.Server.Voice
return UpdateParametersForCommandGeneration(voiceUpdateStates);
}
}
}
}