diff options
author | TSRBerry <20988865+TSRBerry@users.noreply.github.com> | 2023-06-25 01:29:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-25 01:29:40 +0200 |
commit | df5be5812f9ebfd6533ef3eefdcdb24d30f29954 (patch) | |
tree | 890067abfc488a10dd5574947e5ce6c4550e0ea7 | |
parent | bc392e55dfd0eed72ce30a550e91fa480eba1ef9 (diff) |
[Ryujinx.Audio.Backends.OpenAL] Address dotnet-format issues (#5359)1.1.908
* dotnet format style --severity info
Some changes were manually reverted.
* Restore a few unused methods and variables
* Address dotnet format CA1816 warnings
* Address most dotnet format whitespace warnings
* Simplify properties and array initialization, Use const when possible, Remove trailing commas
* Revert "Simplify properties and array initialization, Use const when possible, Remove trailing commas"
This reverts commit 9462e4136c0a2100dc28b20cf9542e06790aa67e.
* dotnet format whitespace after rebase
-rw-r--r-- | src/Ryujinx.Audio.Backends.OpenAL/OpenALHardwareDeviceDriver.cs | 5 | ||||
-rw-r--r-- | src/Ryujinx.Audio.Backends.OpenAL/OpenALHardwareDeviceSession.cs | 36 |
2 files changed, 18 insertions, 23 deletions
diff --git a/src/Ryujinx.Audio.Backends.OpenAL/OpenALHardwareDeviceDriver.cs b/src/Ryujinx.Audio.Backends.OpenAL/OpenALHardwareDeviceDriver.cs index 0c793f24..92946900 100644 --- a/src/Ryujinx.Audio.Backends.OpenAL/OpenALHardwareDeviceDriver.cs +++ b/src/Ryujinx.Audio.Backends.OpenAL/OpenALHardwareDeviceDriver.cs @@ -18,7 +18,7 @@ namespace Ryujinx.Audio.Backends.OpenAL private readonly ManualResetEvent _pauseEvent; private readonly ConcurrentDictionary<OpenALHardwareDeviceSession, byte> _sessions; private bool _stillRunning; - private Thread _updaterThread; + private readonly Thread _updaterThread; public OpenALHardwareDeviceDriver() { @@ -73,7 +73,7 @@ namespace Ryujinx.Audio.Backends.OpenAL throw new ArgumentException($"{channelCount}"); } - OpenALHardwareDeviceSession session = new OpenALHardwareDeviceSession(this, memoryManager, sampleFormat, sampleRate, channelCount, volume); + OpenALHardwareDeviceSession session = new(this, memoryManager, sampleFormat, sampleRate, channelCount, volume); _sessions.TryAdd(session, 0); @@ -123,6 +123,7 @@ namespace Ryujinx.Audio.Backends.OpenAL public void Dispose() { + GC.SuppressFinalize(this); Dispose(true); } diff --git a/src/Ryujinx.Audio.Backends.OpenAL/OpenALHardwareDeviceSession.cs b/src/Ryujinx.Audio.Backends.OpenAL/OpenALHardwareDeviceSession.cs index 8d7d0d6a..4a2d521f 100644 --- a/src/Ryujinx.Audio.Backends.OpenAL/OpenALHardwareDeviceSession.cs +++ b/src/Ryujinx.Audio.Backends.OpenAL/OpenALHardwareDeviceSession.cs @@ -10,11 +10,11 @@ namespace Ryujinx.Audio.Backends.OpenAL { class OpenALHardwareDeviceSession : HardwareDeviceSessionOutputBase { - private OpenALHardwareDeviceDriver _driver; - private int _sourceId; - private ALFormat _targetFormat; + private readonly OpenALHardwareDeviceDriver _driver; + private readonly int _sourceId; + private readonly ALFormat _targetFormat; private bool _isActive; - private Queue<OpenALAudioBuffer> _queuedBuffers; + private readonly Queue<OpenALAudioBuffer> _queuedBuffers; private ulong _playedSampleCount; private readonly object _lock = new(); @@ -32,23 +32,17 @@ namespace Ryujinx.Audio.Backends.OpenAL private ALFormat GetALFormat() { - switch (RequestedSampleFormat) + return RequestedSampleFormat switch { - case SampleFormat.PcmInt16: - switch (RequestedChannelCount) - { - case 1: - return ALFormat.Mono16; - case 2: - return ALFormat.Stereo16; - case 6: - return ALFormat.Multi51Chn16Ext; - default: - throw new NotImplementedException($"Unsupported channel config {RequestedChannelCount}"); - } - default: - throw new NotImplementedException($"Unsupported sample format {RequestedSampleFormat}"); - } + SampleFormat.PcmInt16 => RequestedChannelCount switch + { + 1 => ALFormat.Mono16, + 2 => ALFormat.Stereo16, + 6 => ALFormat.Multi51Chn16Ext, + _ => throw new NotImplementedException($"Unsupported channel config {RequestedChannelCount}"), + }, + _ => throw new NotImplementedException($"Unsupported sample format {RequestedSampleFormat}"), + }; } public override void PrepareToClose() { } @@ -69,7 +63,7 @@ namespace Ryujinx.Audio.Backends.OpenAL { lock (_lock) { - OpenALAudioBuffer driverBuffer = new OpenALAudioBuffer + OpenALAudioBuffer driverBuffer = new() { DriverIdentifier = buffer.DataPointer, BufferId = AL.GenBuffer(), |