mirror of
https://github.com/GreemDev/Ryujinx.git
synced 2024-11-24 18:20:12 +01:00
[Ryujinx.Audio.Backends.SoundIo] Address dotnet-format issues (#5360)
* dotnet format style --severity info Some changes were manually reverted. * Address dotnet format CA1816 warnings * Address dotnet format CA1401 warnings * Address most dotnet format whitespace warnings * Run dotnet format after rebase and remove unused usings - analyzers - style - whitespace * 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 * Address review feedback
This commit is contained in:
parent
df5be5812f
commit
ede5b3c324
@ -10,19 +10,19 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
|||||||
private const string LibraryName = "libsoundio";
|
private const string LibraryName = "libsoundio";
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public unsafe delegate void OnDeviceChangeNativeDelegate(IntPtr ctx);
|
public delegate void OnDeviceChangeNativeDelegate(IntPtr ctx);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public unsafe delegate void OnBackendDisconnectedDelegate(IntPtr ctx, SoundIoError err);
|
public delegate void OnBackendDisconnectedDelegate(IntPtr ctx, SoundIoError err);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public unsafe delegate void OnEventsSignalDelegate(IntPtr ctx);
|
public delegate void OnEventsSignalDelegate(IntPtr ctx);
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public unsafe delegate void EmitRtPrioWarningDelegate();
|
public delegate void EmitRtPrioWarningDelegate();
|
||||||
|
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
public unsafe delegate void JackCallbackDelegate(IntPtr msg);
|
public delegate void JackCallbackDelegate(IntPtr msg);
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
public struct SoundIoStruct
|
public struct SoundIoStruct
|
||||||
@ -110,69 +110,69 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
|||||||
}
|
}
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial IntPtr soundio_create();
|
internal static partial IntPtr soundio_create();
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial SoundIoError soundio_connect(IntPtr ctx);
|
internal static partial SoundIoError soundio_connect(IntPtr ctx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial void soundio_disconnect(IntPtr ctx);
|
internal static partial void soundio_disconnect(IntPtr ctx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial void soundio_flush_events(IntPtr ctx);
|
internal static partial void soundio_flush_events(IntPtr ctx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial int soundio_output_device_count(IntPtr ctx);
|
internal static partial int soundio_output_device_count(IntPtr ctx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial int soundio_default_output_device_index(IntPtr ctx);
|
internal static partial int soundio_default_output_device_index(IntPtr ctx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial IntPtr soundio_get_output_device(IntPtr ctx, int index);
|
internal static partial IntPtr soundio_get_output_device(IntPtr ctx, int index);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static partial bool soundio_device_supports_format(IntPtr devCtx, SoundIoFormat format);
|
internal static partial bool soundio_device_supports_format(IntPtr devCtx, SoundIoFormat format);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static partial bool soundio_device_supports_layout(IntPtr devCtx, IntPtr layout);
|
internal static partial bool soundio_device_supports_layout(IntPtr devCtx, IntPtr layout);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
[return: MarshalAs(UnmanagedType.Bool)]
|
[return: MarshalAs(UnmanagedType.Bool)]
|
||||||
public static partial bool soundio_device_supports_sample_rate(IntPtr devCtx, int sampleRate);
|
internal static partial bool soundio_device_supports_sample_rate(IntPtr devCtx, int sampleRate);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial IntPtr soundio_outstream_create(IntPtr devCtx);
|
internal static partial IntPtr soundio_outstream_create(IntPtr devCtx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial SoundIoError soundio_outstream_open(IntPtr outStreamCtx);
|
internal static partial SoundIoError soundio_outstream_open(IntPtr outStreamCtx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial SoundIoError soundio_outstream_start(IntPtr outStreamCtx);
|
internal static partial SoundIoError soundio_outstream_start(IntPtr outStreamCtx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial SoundIoError soundio_outstream_begin_write(IntPtr outStreamCtx, IntPtr areas, IntPtr frameCount);
|
internal static partial SoundIoError soundio_outstream_begin_write(IntPtr outStreamCtx, IntPtr areas, IntPtr frameCount);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial SoundIoError soundio_outstream_end_write(IntPtr outStreamCtx);
|
internal static partial SoundIoError soundio_outstream_end_write(IntPtr outStreamCtx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial SoundIoError soundio_outstream_pause(IntPtr devCtx, [MarshalAs(UnmanagedType.Bool)] bool pause);
|
internal static partial SoundIoError soundio_outstream_pause(IntPtr devCtx, [MarshalAs(UnmanagedType.Bool)] bool pause);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial SoundIoError soundio_outstream_set_volume(IntPtr devCtx, double volume);
|
internal static partial SoundIoError soundio_outstream_set_volume(IntPtr devCtx, double volume);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial void soundio_outstream_destroy(IntPtr streamCtx);
|
internal static partial void soundio_outstream_destroy(IntPtr streamCtx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial void soundio_destroy(IntPtr ctx);
|
internal static partial void soundio_destroy(IntPtr ctx);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial IntPtr soundio_channel_layout_get_default(int channelCount);
|
internal static partial IntPtr soundio_channel_layout_get_default(int channelCount);
|
||||||
|
|
||||||
[LibraryImport(LibraryName)]
|
[LibraryImport(LibraryName)]
|
||||||
public static partial IntPtr soundio_strerror(SoundIoError err);
|
internal static partial IntPtr soundio_strerror(SoundIoError err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reflection.Metadata;
|
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
@ -141,7 +141,7 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
|||||||
throw new NotImplementedException("Input direction is currently not implemented on SoundIO backend!");
|
throw new NotImplementedException("Input direction is currently not implemented on SoundIO backend!");
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundIoHardwareDeviceSession session = new SoundIoHardwareDeviceSession(this, memoryManager, sampleFormat, sampleRate, channelCount, volume);
|
SoundIoHardwareDeviceSession session = new(this, memoryManager, sampleFormat, sampleRate, channelCount, volume);
|
||||||
|
|
||||||
_sessions.TryAdd(session, 0);
|
_sessions.TryAdd(session, 0);
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
|||||||
SampleFormat.PcmInt24 => SoundIoFormat.S24LE,
|
SampleFormat.PcmInt24 => SoundIoFormat.S24LE,
|
||||||
SampleFormat.PcmInt32 => SoundIoFormat.S32LE,
|
SampleFormat.PcmInt32 => SoundIoFormat.S32LE,
|
||||||
SampleFormat.PcmFloat => SoundIoFormat.Float32LE,
|
SampleFormat.PcmFloat => SoundIoFormat.Float32LE,
|
||||||
_ => throw new ArgumentException ($"Unsupported sample format {format}"),
|
_ => throw new ArgumentException($"Unsupported sample format {format}"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -202,6 +202,8 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
|||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
|
||||||
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
|
if (Interlocked.CompareExchange(ref _disposeState, 1, 0) == 0)
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
@ -12,12 +12,12 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
|||||||
{
|
{
|
||||||
class SoundIoHardwareDeviceSession : HardwareDeviceSessionOutputBase
|
class SoundIoHardwareDeviceSession : HardwareDeviceSessionOutputBase
|
||||||
{
|
{
|
||||||
private SoundIoHardwareDeviceDriver _driver;
|
private readonly SoundIoHardwareDeviceDriver _driver;
|
||||||
private ConcurrentQueue<SoundIoAudioBuffer> _queuedBuffers;
|
private readonly ConcurrentQueue<SoundIoAudioBuffer> _queuedBuffers;
|
||||||
private SoundIoOutStreamContext _outputStream;
|
private SoundIoOutStreamContext _outputStream;
|
||||||
private DynamicRingBuffer _ringBuffer;
|
private readonly DynamicRingBuffer _ringBuffer;
|
||||||
private ulong _playedSampleCount;
|
private ulong _playedSampleCount;
|
||||||
private ManualResetEvent _updateRequiredEvent;
|
private readonly ManualResetEvent _updateRequiredEvent;
|
||||||
private int _disposeState;
|
private int _disposeState;
|
||||||
|
|
||||||
public SoundIoHardwareDeviceSession(SoundIoHardwareDeviceDriver driver, IVirtualMemoryManager memoryManager, SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount, float requestedVolume) : base(memoryManager, requestedSampleFormat, requestedSampleRate, requestedChannelCount)
|
public SoundIoHardwareDeviceSession(SoundIoHardwareDeviceDriver driver, IVirtualMemoryManager memoryManager, SampleFormat requestedSampleFormat, uint requestedSampleRate, uint requestedChannelCount, float requestedVolume) : base(memoryManager, requestedSampleFormat, requestedSampleRate, requestedChannelCount)
|
||||||
@ -54,7 +54,7 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
|||||||
|
|
||||||
public override void QueueBuffer(AudioBuffer buffer)
|
public override void QueueBuffer(AudioBuffer buffer)
|
||||||
{
|
{
|
||||||
SoundIoAudioBuffer driverBuffer = new SoundIoAudioBuffer(buffer.DataPointer, GetSampleCount(buffer));
|
SoundIoAudioBuffer driverBuffer = new(buffer.DataPointer, GetSampleCount(buffer));
|
||||||
|
|
||||||
_ringBuffer.Write(buffer.Data, 0, buffer.Data.Length);
|
_ringBuffer.Write(buffer.Data, 0, buffer.Data.Length);
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ namespace Ryujinx.Audio.Backends.SoundIo
|
|||||||
_driver.FlushContextEvents();
|
_driver.FlushContextEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void UnregisterBuffer(AudioBuffer buffer) {}
|
public override void UnregisterBuffer(AudioBuffer buffer) { }
|
||||||
|
|
||||||
public override bool WasBufferFullyConsumed(AudioBuffer buffer)
|
public override bool WasBufferFullyConsumed(AudioBuffer buffer)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user