2023-12-04 13:17:13 +00:00
|
|
|
using Ryujinx.Common.Memory;
|
2022-12-10 23:57:01 +00:00
|
|
|
using System;
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
namespace Ryujinx.Audio.Backends.SoundIo.Native
|
|
|
|
{
|
|
|
|
public static partial class SoundIo
|
|
|
|
{
|
|
|
|
private const string LibraryName = "libsoundio";
|
|
|
|
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
2024-10-26 13:46:41 +00:00
|
|
|
public delegate void OnDeviceChangeNativeDelegate(nint ctx);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
2024-10-26 13:46:41 +00:00
|
|
|
public delegate void OnBackendDisconnectedDelegate(nint ctx, SoundIoError err);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
2024-10-26 13:46:41 +00:00
|
|
|
public delegate void OnEventsSignalDelegate(nint ctx);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
2023-06-25 00:15:56 +00:00
|
|
|
public delegate void EmitRtPrioWarningDelegate();
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
2024-10-26 13:46:41 +00:00
|
|
|
public delegate void JackCallbackDelegate(nint msg);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
public struct SoundIoStruct
|
|
|
|
{
|
2024-10-26 13:46:41 +00:00
|
|
|
public nint UserData;
|
|
|
|
public nint OnDeviceChange;
|
|
|
|
public nint OnBackendDisconnected;
|
|
|
|
public nint OnEventsSignal;
|
2022-12-10 23:57:01 +00:00
|
|
|
public SoundIoBackend CurrentBackend;
|
2024-10-26 13:46:41 +00:00
|
|
|
public nint ApplicationName;
|
|
|
|
public nint EmitRtPrioWarning;
|
|
|
|
public nint JackInfoCallback;
|
|
|
|
public nint JackErrorCallback;
|
2022-12-10 23:57:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public struct SoundIoChannelLayout
|
|
|
|
{
|
2024-10-26 13:46:41 +00:00
|
|
|
public nint Name;
|
2022-12-10 23:57:01 +00:00
|
|
|
public int ChannelCount;
|
|
|
|
public Array24<SoundIoChannelId> Channels;
|
|
|
|
|
2024-10-26 13:46:41 +00:00
|
|
|
public static nint GetDefault(int channelCount)
|
2022-12-10 23:57:01 +00:00
|
|
|
{
|
|
|
|
return soundio_channel_layout_get_default(channelCount);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static unsafe SoundIoChannelLayout GetDefaultValue(int channelCount)
|
|
|
|
{
|
|
|
|
return Unsafe.AsRef<SoundIoChannelLayout>((SoundIoChannelLayout*)GetDefault(channelCount));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public struct SoundIoSampleRateRange
|
|
|
|
{
|
|
|
|
public int Min;
|
|
|
|
public int Max;
|
|
|
|
}
|
|
|
|
|
|
|
|
public struct SoundIoDevice
|
|
|
|
{
|
2024-10-26 13:46:41 +00:00
|
|
|
public nint SoundIo;
|
|
|
|
public nint Id;
|
|
|
|
public nint Name;
|
2022-12-10 23:57:01 +00:00
|
|
|
public SoundIoDeviceAim Aim;
|
2024-10-26 13:46:41 +00:00
|
|
|
public nint Layouts;
|
2022-12-10 23:57:01 +00:00
|
|
|
public int LayoutCount;
|
|
|
|
public SoundIoChannelLayout CurrentLayout;
|
2024-10-26 13:46:41 +00:00
|
|
|
public nint Formats;
|
2022-12-10 23:57:01 +00:00
|
|
|
public int FormatCount;
|
|
|
|
public SoundIoFormat CurrentFormat;
|
2024-10-26 13:46:41 +00:00
|
|
|
public nint SampleRates;
|
2022-12-10 23:57:01 +00:00
|
|
|
public int SampleRateCount;
|
|
|
|
public int SampleRateCurrent;
|
|
|
|
public double SoftwareLatencyMin;
|
|
|
|
public double SoftwareLatencyMax;
|
|
|
|
public double SoftwareLatencyCurrent;
|
|
|
|
public bool IsRaw;
|
|
|
|
public int RefCount;
|
|
|
|
public SoundIoError ProbeError;
|
|
|
|
}
|
|
|
|
|
|
|
|
public struct SoundIoOutStream
|
|
|
|
{
|
2024-10-26 13:46:41 +00:00
|
|
|
public nint Device;
|
2022-12-10 23:57:01 +00:00
|
|
|
public SoundIoFormat Format;
|
|
|
|
public int SampleRate;
|
|
|
|
public SoundIoChannelLayout Layout;
|
|
|
|
public double SoftwareLatency;
|
|
|
|
public float Volume;
|
2024-10-26 13:46:41 +00:00
|
|
|
public nint UserData;
|
|
|
|
public nint WriteCallback;
|
|
|
|
public nint UnderflowCallback;
|
|
|
|
public nint ErrorCallback;
|
|
|
|
public nint Name;
|
2022-12-10 23:57:01 +00:00
|
|
|
public bool NonTerminalHint;
|
|
|
|
public int BytesPerFrame;
|
|
|
|
public int BytesPerSample;
|
|
|
|
public SoundIoError LayoutError;
|
|
|
|
}
|
|
|
|
|
|
|
|
public struct SoundIoChannelArea
|
|
|
|
{
|
2024-10-26 13:46:41 +00:00
|
|
|
public nint Pointer;
|
2022-12-10 23:57:01 +00:00
|
|
|
public int Step;
|
|
|
|
}
|
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial nint soundio_create();
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial SoundIoError soundio_connect(nint ctx);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial void soundio_disconnect(nint ctx);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial void soundio_flush_events(nint ctx);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial int soundio_output_device_count(nint ctx);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial int soundio_default_output_device_index(nint ctx);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial nint soundio_get_output_device(nint ctx, int index);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
|
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial bool soundio_device_supports_format(nint devCtx, SoundIoFormat format);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
|
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial bool soundio_device_supports_layout(nint devCtx, nint layout);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
|
|
|
[return: MarshalAs(UnmanagedType.Bool)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial bool soundio_device_supports_sample_rate(nint devCtx, int sampleRate);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial nint soundio_outstream_create(nint devCtx);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial SoundIoError soundio_outstream_open(nint outStreamCtx);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial SoundIoError soundio_outstream_start(nint outStreamCtx);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial SoundIoError soundio_outstream_begin_write(nint outStreamCtx, nint areas, nint frameCount);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial SoundIoError soundio_outstream_end_write(nint outStreamCtx);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial SoundIoError soundio_outstream_pause(nint devCtx, [MarshalAs(UnmanagedType.Bool)] bool pause);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial SoundIoError soundio_outstream_set_volume(nint devCtx, double volume);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial void soundio_outstream_destroy(nint streamCtx);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial void soundio_destroy(nint ctx);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial nint soundio_channel_layout_get_default(int channelCount);
|
2022-12-10 23:57:01 +00:00
|
|
|
|
|
|
|
[LibraryImport(LibraryName)]
|
2024-10-26 13:46:41 +00:00
|
|
|
internal static partial nint soundio_strerror(SoundIoError err);
|
2022-12-10 23:57:01 +00:00
|
|
|
}
|
|
|
|
}
|