mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2026-03-11 17:45:43 +00:00
audio backend projects code cleanup
This commit is contained in:
parent
bd388cf4f9
commit
82074eb191
9 changed files with 42 additions and 60 deletions
|
|
@ -15,7 +15,7 @@ namespace Ryujinx.Audio.Backends.Apple
|
||||||
{
|
{
|
||||||
[SupportedOSPlatform("macos")]
|
[SupportedOSPlatform("macos")]
|
||||||
[SupportedOSPlatform("ios")]
|
[SupportedOSPlatform("ios")]
|
||||||
public class AppleHardwareDeviceDriver : IHardwareDeviceDriver
|
public sealed class AppleHardwareDeviceDriver : IHardwareDeviceDriver
|
||||||
{
|
{
|
||||||
private readonly ManualResetEvent _updateRequiredEvent;
|
private readonly ManualResetEvent _updateRequiredEvent;
|
||||||
private readonly ManualResetEvent _pauseEvent;
|
private readonly ManualResetEvent _pauseEvent;
|
||||||
|
|
@ -39,7 +39,8 @@ namespace Ryujinx.Audio.Backends.Apple
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var format = GetAudioFormat(SampleFormat.PcmFloat, Constants.TargetSampleRate, 6);
|
AudioStreamBasicDescription format =
|
||||||
|
GetAudioFormat(SampleFormat.PcmFloat, Constants.TargetSampleRate, 6);
|
||||||
|
|
||||||
int result = AudioQueueNewOutput(
|
int result = AudioQueueNewOutput(
|
||||||
ref format,
|
ref format,
|
||||||
|
|
@ -90,7 +91,8 @@ namespace Ryujinx.Audio.Backends.Apple
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var format = GetAudioFormat(SampleFormat.PcmInt16, Constants.TargetSampleRate, 2);
|
AudioStreamBasicDescription format =
|
||||||
|
GetAudioFormat(SampleFormat.PcmInt16, Constants.TargetSampleRate, 2);
|
||||||
int result = AudioQueueNewOutput(
|
int result = AudioQueueNewOutput(
|
||||||
ref format,
|
ref format,
|
||||||
IntPtr.Zero,
|
IntPtr.Zero,
|
||||||
|
|
@ -115,16 +117,13 @@ namespace Ryujinx.Audio.Backends.Apple
|
||||||
}
|
}
|
||||||
|
|
||||||
public ManualResetEvent GetUpdateRequiredEvent()
|
public ManualResetEvent GetUpdateRequiredEvent()
|
||||||
{
|
=> _updateRequiredEvent;
|
||||||
return _updateRequiredEvent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ManualResetEvent GetPauseEvent()
|
public ManualResetEvent GetPauseEvent()
|
||||||
{
|
=> _pauseEvent;
|
||||||
return _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)
|
if (channelCount == 0)
|
||||||
{
|
{
|
||||||
|
|
@ -149,11 +148,10 @@ namespace Ryujinx.Audio.Backends.Apple
|
||||||
}
|
}
|
||||||
|
|
||||||
internal bool Unregister(AppleHardwareDeviceSession session)
|
internal bool Unregister(AppleHardwareDeviceSession session)
|
||||||
{
|
=> _sessions.TryRemove(session, out _);
|
||||||
return _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 formatFlags;
|
||||||
uint bitsPerChannel;
|
uint bitsPerChannel;
|
||||||
|
|
@ -202,7 +200,7 @@ namespace Ryujinx.Audio.Backends.Apple
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
private void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
{
|
{
|
||||||
|
|
@ -215,29 +213,15 @@ namespace Ryujinx.Audio.Backends.Apple
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SupportsSampleRate(uint sampleRate)
|
public bool SupportsDirection(Direction direction)
|
||||||
{
|
=> direction != Direction.Input;
|
||||||
return true;
|
|
||||||
}
|
public bool SupportsSampleRate(uint sampleRate) => true;
|
||||||
|
|
||||||
public bool SupportsSampleFormat(SampleFormat sampleFormat)
|
public bool SupportsSampleFormat(SampleFormat sampleFormat)
|
||||||
{
|
=> sampleFormat != SampleFormat.PcmInt24;
|
||||||
return sampleFormat != SampleFormat.PcmInt24;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SupportsChannelCount(uint channelCount)
|
public bool SupportsChannelCount(uint channelCount)
|
||||||
{
|
=> channelCount != 6 || _supportSurroundConfiguration;
|
||||||
if (channelCount == 6)
|
|
||||||
{
|
|
||||||
return _supportSurroundConfiguration;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SupportsDirection(Direction direction)
|
|
||||||
{
|
|
||||||
return direction != Direction.Input;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -67,7 +67,7 @@ namespace Ryujinx.Audio.Backends.Apple
|
||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
var format = AppleHardwareDeviceDriver.GetAudioFormat(
|
AudioStreamBasicDescription format = AppleHardwareDeviceDriver.GetAudioFormat(
|
||||||
RequestedSampleFormat,
|
RequestedSampleFormat,
|
||||||
RequestedSampleRate,
|
RequestedSampleRate,
|
||||||
RequestedChannelCount);
|
RequestedChannelCount);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
using Ryujinx.Common.Memory;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
// ReSharper disable InconsistentNaming
|
||||||
|
|
||||||
namespace Ryujinx.Audio.Backends.Apple.Native
|
namespace Ryujinx.Audio.Backends.Apple.Native
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,8 @@ using static Ryujinx.Audio.Integration.IHardwareDeviceDriver;
|
||||||
|
|
||||||
namespace Ryujinx.Audio.Backends.OpenAL
|
namespace Ryujinx.Audio.Backends.OpenAL
|
||||||
{
|
{
|
||||||
public class OpenALHardwareDeviceDriver : IHardwareDeviceDriver
|
// ReSharper disable once InconsistentNaming
|
||||||
|
public sealed class OpenALHardwareDeviceDriver : IHardwareDeviceDriver
|
||||||
{
|
{
|
||||||
private readonly ALDevice _device;
|
private readonly ALDevice _device;
|
||||||
private readonly ALContext _context;
|
private readonly ALContext _context;
|
||||||
|
|
@ -148,7 +149,7 @@ namespace Ryujinx.Audio.Backends.OpenAL
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
private void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@ using System.Threading;
|
||||||
|
|
||||||
namespace Ryujinx.Audio.Backends.OpenAL
|
namespace Ryujinx.Audio.Backends.OpenAL
|
||||||
{
|
{
|
||||||
class OpenALHardwareDeviceSession : HardwareDeviceSessionOutputBase
|
// ReSharper disable once InconsistentNaming
|
||||||
|
sealed class OpenALHardwareDeviceSession : HardwareDeviceSessionOutputBase
|
||||||
{
|
{
|
||||||
private readonly OpenALHardwareDeviceDriver _driver;
|
private readonly OpenALHardwareDeviceDriver _driver;
|
||||||
private readonly int _sourceId;
|
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))
|
if (disposing && _driver.Unregister(this))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ namespace Ryujinx.Audio.Backends.SDL3
|
||||||
|
|
||||||
using unsafe SDL_AudioStreamCallbackPointer = delegate* unmanaged[Cdecl]<nint, SDL_AudioStream*, int, int, void>;
|
using unsafe SDL_AudioStreamCallbackPointer = delegate* unmanaged[Cdecl]<nint, SDL_AudioStream*, int, int, void>;
|
||||||
|
|
||||||
public class SDL3HardwareDeviceDriver : IHardwareDeviceDriver
|
public sealed class SDL3HardwareDeviceDriver : IHardwareDeviceDriver
|
||||||
{
|
{
|
||||||
private readonly ManualResetEvent _updateRequiredEvent;
|
private readonly ManualResetEvent _updateRequiredEvent;
|
||||||
private readonly ManualResetEvent _pauseEvent;
|
private readonly ManualResetEvent _pauseEvent;
|
||||||
|
|
@ -162,7 +162,7 @@ namespace Ryujinx.Audio.Backends.SDL3
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
private void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing)
|
if (disposing)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -12,10 +12,7 @@ using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace Ryujinx.Audio.Backends.SDL3
|
namespace Ryujinx.Audio.Backends.SDL3
|
||||||
{
|
{
|
||||||
|
sealed unsafe class SDL3HardwareDeviceSession : HardwareDeviceSessionOutputBase
|
||||||
|
|
||||||
|
|
||||||
unsafe class SDL3HardwareDeviceSession : HardwareDeviceSessionOutputBase
|
|
||||||
{
|
{
|
||||||
private readonly SDL3HardwareDeviceDriver _driver;
|
private readonly SDL3HardwareDeviceDriver _driver;
|
||||||
private readonly ConcurrentQueue<SDL3AudioBuffer> _queuedBuffers;
|
private readonly ConcurrentQueue<SDL3AudioBuffer> _queuedBuffers;
|
||||||
|
|
@ -226,7 +223,7 @@ namespace Ryujinx.Audio.Backends.SDL3
|
||||||
return driverBuffer.DriverIdentifier != buffer.DataPointer;
|
return driverBuffer.DriverIdentifier != buffer.DataPointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
private void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
if (disposing && _driver.Unregister(this))
|
if (disposing && _driver.Unregister(this))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ using static Ryujinx.Audio.Integration.IHardwareDeviceDriver;
|
||||||
|
|
||||||
namespace Ryujinx.Audio.Backends.SoundIo
|
namespace Ryujinx.Audio.Backends.SoundIo
|
||||||
{
|
{
|
||||||
public class SoundIoHardwareDeviceDriver : IHardwareDeviceDriver
|
public sealed class SoundIoHardwareDeviceDriver : IHardwareDeviceDriver
|
||||||
{
|
{
|
||||||
private readonly SoundIoContext _audioContext;
|
private readonly SoundIoContext _audioContext;
|
||||||
private readonly SoundIoDeviceContext _audioDevice;
|
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)
|
if (disposing)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ using static Ryujinx.Audio.Backends.SoundIo.Native.SoundIo;
|
||||||
|
|
||||||
namespace Ryujinx.Audio.Backends.SoundIo
|
namespace Ryujinx.Audio.Backends.SoundIo
|
||||||
{
|
{
|
||||||
class SoundIoHardwareDeviceSession : HardwareDeviceSessionOutputBase
|
sealed class SoundIoHardwareDeviceSession : HardwareDeviceSessionOutputBase
|
||||||
{
|
{
|
||||||
private readonly SoundIoHardwareDeviceDriver _driver;
|
private readonly SoundIoHardwareDeviceDriver _driver;
|
||||||
private readonly ConcurrentQueue<SoundIoAudioBuffer> _queuedBuffers;
|
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))
|
if (disposing && _driver.Unregister(this))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue