mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-23 00:07:10 +02:00
misc: Replace references to IntPtr/UIntPtr with nint/nuint + code cleanups.
This commit is contained in:
parent
a09d314817
commit
dfb4854d19
172 changed files with 902 additions and 914 deletions
|
@ -10,41 +10,41 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
|||
private const string LibraryName = "libsoundio";
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void OnDeviceChangeNativeDelegate(IntPtr ctx);
|
||||
public delegate void OnDeviceChangeNativeDelegate(nint ctx);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void OnBackendDisconnectedDelegate(IntPtr ctx, SoundIoError err);
|
||||
public delegate void OnBackendDisconnectedDelegate(nint ctx, SoundIoError err);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void OnEventsSignalDelegate(IntPtr ctx);
|
||||
public delegate void OnEventsSignalDelegate(nint ctx);
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void EmitRtPrioWarningDelegate();
|
||||
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
public delegate void JackCallbackDelegate(IntPtr msg);
|
||||
public delegate void JackCallbackDelegate(nint msg);
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct SoundIoStruct
|
||||
{
|
||||
public IntPtr UserData;
|
||||
public IntPtr OnDeviceChange;
|
||||
public IntPtr OnBackendDisconnected;
|
||||
public IntPtr OnEventsSignal;
|
||||
public nint UserData;
|
||||
public nint OnDeviceChange;
|
||||
public nint OnBackendDisconnected;
|
||||
public nint OnEventsSignal;
|
||||
public SoundIoBackend CurrentBackend;
|
||||
public IntPtr ApplicationName;
|
||||
public IntPtr EmitRtPrioWarning;
|
||||
public IntPtr JackInfoCallback;
|
||||
public IntPtr JackErrorCallback;
|
||||
public nint ApplicationName;
|
||||
public nint EmitRtPrioWarning;
|
||||
public nint JackInfoCallback;
|
||||
public nint JackErrorCallback;
|
||||
}
|
||||
|
||||
public struct SoundIoChannelLayout
|
||||
{
|
||||
public IntPtr Name;
|
||||
public nint Name;
|
||||
public int ChannelCount;
|
||||
public Array24<SoundIoChannelId> Channels;
|
||||
|
||||
public static IntPtr GetDefault(int channelCount)
|
||||
public static nint GetDefault(int channelCount)
|
||||
{
|
||||
return soundio_channel_layout_get_default(channelCount);
|
||||
}
|
||||
|
@ -63,17 +63,17 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
|||
|
||||
public struct SoundIoDevice
|
||||
{
|
||||
public IntPtr SoundIo;
|
||||
public IntPtr Id;
|
||||
public IntPtr Name;
|
||||
public nint SoundIo;
|
||||
public nint Id;
|
||||
public nint Name;
|
||||
public SoundIoDeviceAim Aim;
|
||||
public IntPtr Layouts;
|
||||
public nint Layouts;
|
||||
public int LayoutCount;
|
||||
public SoundIoChannelLayout CurrentLayout;
|
||||
public IntPtr Formats;
|
||||
public nint Formats;
|
||||
public int FormatCount;
|
||||
public SoundIoFormat CurrentFormat;
|
||||
public IntPtr SampleRates;
|
||||
public nint SampleRates;
|
||||
public int SampleRateCount;
|
||||
public int SampleRateCurrent;
|
||||
public double SoftwareLatencyMin;
|
||||
|
@ -86,17 +86,17 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
|||
|
||||
public struct SoundIoOutStream
|
||||
{
|
||||
public IntPtr Device;
|
||||
public nint Device;
|
||||
public SoundIoFormat Format;
|
||||
public int SampleRate;
|
||||
public SoundIoChannelLayout Layout;
|
||||
public double SoftwareLatency;
|
||||
public float Volume;
|
||||
public IntPtr UserData;
|
||||
public IntPtr WriteCallback;
|
||||
public IntPtr UnderflowCallback;
|
||||
public IntPtr ErrorCallback;
|
||||
public IntPtr Name;
|
||||
public nint UserData;
|
||||
public nint WriteCallback;
|
||||
public nint UnderflowCallback;
|
||||
public nint ErrorCallback;
|
||||
public nint Name;
|
||||
public bool NonTerminalHint;
|
||||
public int BytesPerFrame;
|
||||
public int BytesPerSample;
|
||||
|
@ -105,74 +105,74 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
|||
|
||||
public struct SoundIoChannelArea
|
||||
{
|
||||
public IntPtr Pointer;
|
||||
public nint Pointer;
|
||||
public int Step;
|
||||
}
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
internal static partial IntPtr soundio_create();
|
||||
internal static partial nint soundio_create();
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
internal static partial SoundIoError soundio_connect(IntPtr ctx);
|
||||
internal static partial SoundIoError soundio_connect(nint ctx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
internal static partial void soundio_disconnect(IntPtr ctx);
|
||||
internal static partial void soundio_disconnect(nint ctx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
internal static partial void soundio_flush_events(IntPtr ctx);
|
||||
internal static partial void soundio_flush_events(nint ctx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
internal static partial int soundio_output_device_count(IntPtr ctx);
|
||||
internal static partial int soundio_output_device_count(nint ctx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
internal static partial int soundio_default_output_device_index(IntPtr ctx);
|
||||
internal static partial int soundio_default_output_device_index(nint ctx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
internal static partial IntPtr soundio_get_output_device(IntPtr ctx, int index);
|
||||
internal static partial nint soundio_get_output_device(nint ctx, int index);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static partial bool soundio_device_supports_format(IntPtr devCtx, SoundIoFormat format);
|
||||
internal static partial bool soundio_device_supports_format(nint devCtx, SoundIoFormat format);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static partial bool soundio_device_supports_layout(IntPtr devCtx, IntPtr layout);
|
||||
internal static partial bool soundio_device_supports_layout(nint devCtx, nint layout);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
internal static partial bool soundio_device_supports_sample_rate(IntPtr devCtx, int sampleRate);
|
||||
internal static partial bool soundio_device_supports_sample_rate(nint devCtx, int sampleRate);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
internal static partial IntPtr soundio_outstream_create(IntPtr devCtx);
|
||||
internal static partial nint soundio_outstream_create(nint devCtx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
internal static partial SoundIoError soundio_outstream_open(IntPtr outStreamCtx);
|
||||
internal static partial SoundIoError soundio_outstream_open(nint outStreamCtx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
internal static partial SoundIoError soundio_outstream_start(IntPtr outStreamCtx);
|
||||
internal static partial SoundIoError soundio_outstream_start(nint outStreamCtx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
internal static partial SoundIoError soundio_outstream_begin_write(IntPtr outStreamCtx, IntPtr areas, IntPtr frameCount);
|
||||
internal static partial SoundIoError soundio_outstream_begin_write(nint outStreamCtx, nint areas, nint frameCount);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
internal static partial SoundIoError soundio_outstream_end_write(IntPtr outStreamCtx);
|
||||
internal static partial SoundIoError soundio_outstream_end_write(nint outStreamCtx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
internal static partial SoundIoError soundio_outstream_pause(IntPtr devCtx, [MarshalAs(UnmanagedType.Bool)] bool pause);
|
||||
internal static partial SoundIoError soundio_outstream_pause(nint devCtx, [MarshalAs(UnmanagedType.Bool)] bool pause);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
internal static partial SoundIoError soundio_outstream_set_volume(IntPtr devCtx, double volume);
|
||||
internal static partial SoundIoError soundio_outstream_set_volume(nint devCtx, double volume);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
internal static partial void soundio_outstream_destroy(IntPtr streamCtx);
|
||||
internal static partial void soundio_outstream_destroy(nint streamCtx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
internal static partial void soundio_destroy(IntPtr ctx);
|
||||
internal static partial void soundio_destroy(nint ctx);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
internal static partial IntPtr soundio_channel_layout_get_default(int channelCount);
|
||||
internal static partial nint soundio_channel_layout_get_default(int channelCount);
|
||||
|
||||
[LibraryImport(LibraryName)]
|
||||
internal static partial IntPtr soundio_strerror(SoundIoError err);
|
||||
internal static partial nint soundio_strerror(SoundIoError err);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,13 +8,13 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
|||
{
|
||||
public class SoundIoContext : IDisposable
|
||||
{
|
||||
private IntPtr _context;
|
||||
private nint _context;
|
||||
private Action<SoundIoError> _onBackendDisconnect;
|
||||
private OnBackendDisconnectedDelegate _onBackendDisconnectNative;
|
||||
|
||||
public IntPtr Context => _context;
|
||||
public nint Context => _context;
|
||||
|
||||
internal SoundIoContext(IntPtr context)
|
||||
internal SoundIoContext(nint context)
|
||||
{
|
||||
_context = context;
|
||||
_onBackendDisconnect = null;
|
||||
|
@ -60,9 +60,9 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
|||
|
||||
public SoundIoDeviceContext GetOutputDevice(int index)
|
||||
{
|
||||
IntPtr deviceContext = soundio_get_output_device(_context, index);
|
||||
nint deviceContext = soundio_get_output_device(_context, index);
|
||||
|
||||
if (deviceContext == IntPtr.Zero)
|
||||
if (deviceContext == nint.Zero)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -72,9 +72,9 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
|||
|
||||
public static SoundIoContext Create()
|
||||
{
|
||||
IntPtr context = soundio_create();
|
||||
nint context = soundio_create();
|
||||
|
||||
if (context == IntPtr.Zero)
|
||||
if (context == nint.Zero)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
@ -84,9 +84,9 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
|||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
IntPtr currentContext = Interlocked.Exchange(ref _context, IntPtr.Zero);
|
||||
nint currentContext = Interlocked.Exchange(ref _context, nint.Zero);
|
||||
|
||||
if (currentContext != IntPtr.Zero)
|
||||
if (currentContext != nint.Zero)
|
||||
{
|
||||
soundio_destroy(currentContext);
|
||||
}
|
||||
|
|
|
@ -7,11 +7,11 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
|||
{
|
||||
public class SoundIoDeviceContext
|
||||
{
|
||||
private readonly IntPtr _context;
|
||||
private readonly nint _context;
|
||||
|
||||
public IntPtr Context => _context;
|
||||
public nint Context => _context;
|
||||
|
||||
internal SoundIoDeviceContext(IntPtr context)
|
||||
internal SoundIoDeviceContext(nint context)
|
||||
{
|
||||
_context = context;
|
||||
}
|
||||
|
@ -36,9 +36,9 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
|||
|
||||
public SoundIoOutStreamContext CreateOutStream()
|
||||
{
|
||||
IntPtr context = soundio_outstream_create(_context);
|
||||
nint context = soundio_outstream_create(_context);
|
||||
|
||||
if (context == IntPtr.Zero)
|
||||
if (context == nint.Zero)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -8,19 +8,19 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
|||
public class SoundIoOutStreamContext : IDisposable
|
||||
{
|
||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||
private unsafe delegate void WriteCallbackDelegate(IntPtr ctx, int frameCountMin, int frameCountMax);
|
||||
private unsafe delegate void WriteCallbackDelegate(nint ctx, int frameCountMin, int frameCountMax);
|
||||
|
||||
private IntPtr _context;
|
||||
private IntPtr _nameStored;
|
||||
private nint _context;
|
||||
private nint _nameStored;
|
||||
private Action<int, int> _writeCallback;
|
||||
private WriteCallbackDelegate _writeCallbackNative;
|
||||
|
||||
public IntPtr Context => _context;
|
||||
public nint Context => _context;
|
||||
|
||||
internal SoundIoOutStreamContext(IntPtr context)
|
||||
internal SoundIoOutStreamContext(nint context)
|
||||
{
|
||||
_context = context;
|
||||
_nameStored = IntPtr.Zero;
|
||||
_nameStored = nint.Zero;
|
||||
_writeCallback = null;
|
||||
_writeCallbackNative = null;
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
|||
{
|
||||
var context = GetOutContext();
|
||||
|
||||
if (_nameStored != IntPtr.Zero && context.Name == _nameStored)
|
||||
if (_nameStored != nint.Zero && context.Name == _nameStored)
|
||||
{
|
||||
Marshal.FreeHGlobal(_nameStored);
|
||||
}
|
||||
|
@ -124,14 +124,14 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
|||
|
||||
public Span<SoundIoChannelArea> BeginWrite(ref int frameCount)
|
||||
{
|
||||
IntPtr arenas = default;
|
||||
nint arenas = default;
|
||||
int nativeFrameCount = frameCount;
|
||||
|
||||
unsafe
|
||||
{
|
||||
var frameCountPtr = &nativeFrameCount;
|
||||
var arenasPtr = &arenas;
|
||||
CheckError(soundio_outstream_begin_write(_context, (IntPtr)arenasPtr, (IntPtr)frameCountPtr));
|
||||
CheckError(soundio_outstream_begin_write(_context, (nint)arenasPtr, (nint)frameCountPtr));
|
||||
|
||||
frameCount = *frameCountPtr;
|
||||
|
||||
|
@ -143,10 +143,10 @@ namespace Ryujinx.Audio.Backends.SoundIo.Native
|
|||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (_context != IntPtr.Zero)
|
||||
if (_context != nint.Zero)
|
||||
{
|
||||
soundio_outstream_destroy(_context);
|
||||
_context = IntPtr.Zero;
|
||||
_context = nint.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue