Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Prowl.Runtime/Audio/AudioContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Prowl.Runtime.Audio
public static class AudioContext
{
private static IntPtr audioContext;
private static ma_device_data_proc deviceDataProc;
private static unsafe delegate* unmanaged[Cdecl]<ma_device_ptr, IntPtr, IntPtr, uint, void> deviceDataProc;
private static Dictionary<UInt64, IntPtr> audioClipHandles = new Dictionary<UInt64, IntPtr>();
private static AudioBuffer outputBuffer = new AudioBuffer(8192);

Expand Down Expand Up @@ -108,8 +108,10 @@ public static void Initialize(UInt32 sampleRate, UInt32 channels, UInt32 periodS

ma_ex_context_config contextConfig = MiniAudioExNative.ma_ex_context_config_init(sampleRate, (byte)channels, periodSizeInFrames, ref pDeviceInfo);

deviceDataProc = OnDeviceDataProc;
contextConfig.deviceDataProc = deviceDataProc;
unsafe
{
deviceDataProc = &OnDeviceDataProc;
}

audioContext = MiniAudioExNative.ma_ex_context_init(ref contextConfig);

Expand Down Expand Up @@ -228,6 +230,7 @@ internal static bool GetAudioClipHandle(UInt64 hashcode, out IntPtr handle)
return false;
}

[UnmanagedCallersOnly(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])]
private static void OnDeviceDataProc(ma_device_ptr pDevice, IntPtr pOutput, IntPtr pInput, UInt32 frameCount)
{
IntPtr pEngine = MiniAudioExNative.ma_ex_device_get_user_data(pDevice.pointer);
Expand Down
Loading