Ryujinx/Ryujinx.Audio/Native/libsoundio/MarshalExtensions.cs
jduncanator c734137f41
Audio: Select a shared audio device by default (#574)
* Audio: Select a shared audio device by default

This ensures that a non-raw audio device is selected wherever possible.

* Audio: Resolve libsoundio version mismatch between bindings and binaries

It turns out we were using bindings generated with libsoundio 1.1.0 git source, but the binaries we were using were built from master git source. I've rebuilt both binaries and bindings to ensure they are version matched.

This should resolve all outstanding issues with libsoundio (including the Linux segfault issue, and the "cannot open device" Windows issue).

* Audio: Reformat MarshalExtensions

* Resolve code indentation issues
2019-02-13 12:59:26 +11:00

39 lines
1.1 KiB
C#

using System;
using System.Runtime.InteropServices;
namespace SoundIOSharp
{
public static class MarshalEx
{
public static double ReadDouble(IntPtr handle, int offset = 0)
{
return BitConverter.Int64BitsToDouble(Marshal.ReadInt64(handle, offset));
}
public static void WriteDouble(IntPtr handle, double value)
{
WriteDouble(handle, 0, value);
}
public static void WriteDouble(IntPtr handle, int offset, double value)
{
Marshal.WriteInt64(handle, offset, BitConverter.DoubleToInt64Bits(value));
}
public static float ReadFloat(IntPtr handle, int offset = 0)
{
return BitConverter.Int32BitsToSingle(Marshal.ReadInt32(handle, offset));
}
public static void WriteFloat(IntPtr handle, float value)
{
WriteFloat(handle, 0, value);
}
public static void WriteFloat(IntPtr handle, int offset, float value)
{
Marshal.WriteInt32(handle, offset, BitConverter.SingleToInt32Bits(value));
}
}
}