audio backend projects code cleanup

This commit is contained in:
GreemDev
2026-01-31 02:25:45 -06:00
committed by KeatonTheBot
parent 3cdae775b1
commit 60c867622e
9 changed files with 40 additions and 56 deletions
@@ -13,7 +13,7 @@ namespace Ryujinx.Audio.Backends.Apple
{
[SupportedOSPlatform("macos")]
[SupportedOSPlatform("ios")]
public class AppleHardwareDeviceDriver : IHardwareDeviceDriver
public sealed class AppleHardwareDeviceDriver : IHardwareDeviceDriver
{
private readonly ManualResetEvent _updateRequiredEvent;
private readonly ManualResetEvent _pauseEvent;
@@ -36,9 +36,10 @@ namespace Ryujinx.Audio.Backends.Apple
private bool TestSurroundSupport()
{
try
{
var format = GetAudioFormat(SampleFormat.PcmFloat, Constants.TargetSampleRate, 6);
{
AudioStreamBasicDescription format =
GetAudioFormat(SampleFormat.PcmFloat, Constants.TargetSampleRate, 6);
int result = AudioQueueNewOutput(
ref format,
IntPtr.Zero,
@@ -58,9 +59,9 @@ namespace Ryujinx.Audio.Backends.Apple
};
int layoutResult = AudioQueueSetProperty(
testQueue,
kAudioQueueProperty_ChannelLayout,
ref layout,
testQueue,
kAudioQueueProperty_ChannelLayout,
ref layout,
(uint)Marshal.SizeOf<AudioChannelLayout>());
if (layoutResult == 0)
@@ -68,7 +69,7 @@ namespace Ryujinx.Audio.Backends.Apple
AudioQueueDispose(testQueue, true);
return true;
}
AudioQueueDispose(testQueue, true);
}
@@ -83,16 +84,13 @@ namespace Ryujinx.Audio.Backends.Apple
public static bool IsSupported => OperatingSystem.IsMacOSVersionAtLeast(10, 5);
public ManualResetEvent GetUpdateRequiredEvent()
{
return _updateRequiredEvent;
}
=> _updateRequiredEvent;
public ManualResetEvent GetPauseEvent()
{
return _pauseEvent;
}
=> _pauseEvent;
public IHardwareDeviceSession OpenDeviceSession(Direction direction, IVirtualMemoryManager memoryManager, SampleFormat sampleFormat, uint sampleRate, uint channelCount)
public IHardwareDeviceSession OpenDeviceSession(Direction direction, IVirtualMemoryManager memoryManager,
SampleFormat sampleFormat, uint sampleRate, uint channelCount)
{
if (channelCount == 0)
{
@@ -117,11 +115,10 @@ namespace Ryujinx.Audio.Backends.Apple
}
internal bool Unregister(AppleHardwareDeviceSession session)
{
return _sessions.TryRemove(session, out _);
}
=> _sessions.TryRemove(session, out _);
internal static AudioStreamBasicDescription GetAudioFormat(SampleFormat sampleFormat, uint sampleRate, uint channelCount)
internal static AudioStreamBasicDescription GetAudioFormat(SampleFormat sampleFormat, uint sampleRate,
uint channelCount)
{
uint formatFlags;
uint bitsPerChannel;
@@ -170,7 +167,7 @@ namespace Ryujinx.Audio.Backends.Apple
Dispose(true);
}
protected virtual void Dispose(bool disposing)
private void Dispose(bool disposing)
{
if (disposing)
{
@@ -183,29 +180,15 @@ namespace Ryujinx.Audio.Backends.Apple
}
}
public bool SupportsSampleRate(uint sampleRate)
{
return true;
}
public bool SupportsDirection(Direction direction)
=> direction != Direction.Input;
public bool SupportsSampleRate(uint sampleRate) => true;
public bool SupportsSampleFormat(SampleFormat sampleFormat)
{
return sampleFormat != SampleFormat.PcmInt24;
}
=> sampleFormat != SampleFormat.PcmInt24;
public bool SupportsChannelCount(uint channelCount)
{
if (channelCount == 6)
{
return _supportSurroundConfiguration;
}
return true;
}
public bool SupportsDirection(Direction direction)
{
return direction != Direction.Input;
}
=> channelCount != 6 || _supportSurroundConfiguration;
}
}
@@ -64,7 +64,7 @@ namespace Ryujinx.Audio.Backends.Apple
{
lock (_lock)
{
var format = AppleHardwareDeviceDriver.GetAudioFormat(
AudioStreamBasicDescription format = AppleHardwareDeviceDriver.GetAudioFormat(
RequestedSampleFormat,
RequestedSampleRate,
RequestedChannelCount);
@@ -1,6 +1,5 @@
using Ryujinx.Common.Memory;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// ReSharper disable InconsistentNaming
namespace Ryujinx.Audio.Backends.Apple.Native
{
@@ -100,4 +99,4 @@ namespace Ryujinx.Audio.Backends.Apple.Native
internal const uint kAudioQueueParam_Volume = 1;
}
}
}
@@ -10,7 +10,8 @@ using static Ryujinx.Audio.Integration.IHardwareDeviceDriver;
namespace Ryujinx.Audio.Backends.OpenAL
{
public class OpenALHardwareDeviceDriver : IHardwareDeviceDriver
// ReSharper disable once InconsistentNaming
public sealed class OpenALHardwareDeviceDriver : IHardwareDeviceDriver
{
private readonly ALDevice _device;
private readonly ALContext _context;
@@ -148,7 +149,7 @@ namespace Ryujinx.Audio.Backends.OpenAL
Dispose(true);
}
protected virtual void Dispose(bool disposing)
private void Dispose(bool disposing)
{
if (disposing)
{
@@ -9,7 +9,8 @@ using System.Threading;
namespace Ryujinx.Audio.Backends.OpenAL
{
class OpenALHardwareDeviceSession : HardwareDeviceSessionOutputBase
// ReSharper disable once InconsistentNaming
sealed class OpenALHardwareDeviceSession : HardwareDeviceSessionOutputBase
{
private readonly OpenALHardwareDeviceDriver _driver;
private readonly int _sourceId;
@@ -190,7 +191,7 @@ namespace Ryujinx.Audio.Backends.OpenAL
}
}
protected virtual void Dispose(bool disposing)
private void Dispose(bool disposing)
{
if (disposing && _driver.Unregister(this))
{
@@ -12,7 +12,7 @@ using static SDL2.SDL;
namespace Ryujinx.Audio.Backends.SDL2
{
public class SDL2HardwareDeviceDriver : IHardwareDeviceDriver
public sealed class SDL2HardwareDeviceDriver : IHardwareDeviceDriver
{
private readonly ManualResetEvent _updateRequiredEvent;
private readonly ManualResetEvent _pauseEvent;
@@ -164,7 +164,7 @@ namespace Ryujinx.Audio.Backends.SDL2
Dispose(true);
}
protected virtual void Dispose(bool disposing)
private void Dispose(bool disposing)
{
if (disposing)
{
@@ -11,7 +11,7 @@ using static SDL2.SDL;
namespace Ryujinx.Audio.Backends.SDL2
{
class SDL2HardwareDeviceSession : HardwareDeviceSessionOutputBase
sealed class SDL2HardwareDeviceSession : HardwareDeviceSessionOutputBase
{
private readonly SDL2HardwareDeviceDriver _driver;
private readonly ConcurrentQueue<SDL2AudioBuffer> _queuedBuffers;
@@ -211,7 +211,7 @@ namespace Ryujinx.Audio.Backends.SDL2
return driverBuffer.DriverIdentifier != buffer.DataPointer;
}
protected virtual void Dispose(bool disposing)
private void Dispose(bool disposing)
{
if (disposing && _driver.Unregister(this))
{
@@ -10,7 +10,7 @@ using static Ryujinx.Audio.Integration.IHardwareDeviceDriver;
namespace Ryujinx.Audio.Backends.SoundIo
{
public class SoundIoHardwareDeviceDriver : IHardwareDeviceDriver
public sealed class SoundIoHardwareDeviceDriver : IHardwareDeviceDriver
{
private readonly SoundIoContext _audioContext;
private readonly SoundIoDeviceContext _audioDevice;
@@ -227,7 +227,7 @@ namespace Ryujinx.Audio.Backends.SoundIo
}
}
protected virtual void Dispose(bool disposing)
private void Dispose(bool disposing)
{
if (disposing)
{
@@ -11,7 +11,7 @@ using static Ryujinx.Audio.Backends.SoundIo.Native.SoundIo;
namespace Ryujinx.Audio.Backends.SoundIo
{
class SoundIoHardwareDeviceSession : HardwareDeviceSessionOutputBase
sealed class SoundIoHardwareDeviceSession : HardwareDeviceSessionOutputBase
{
private readonly SoundIoHardwareDeviceDriver _driver;
private readonly ConcurrentQueue<SoundIoAudioBuffer> _queuedBuffers;
@@ -428,7 +428,7 @@ namespace Ryujinx.Audio.Backends.SoundIo
}
}
protected virtual void Dispose(bool disposing)
private void Dispose(bool disposing)
{
if (disposing && _driver.Unregister(this))
{