@@ -18,7 +18,7 @@ namespace Prowl.Runtime.Audio
1818 public static class AudioContext
1919 {
2020 private static IntPtr audioContext ;
21- private static ma_device_data_proc deviceDataProc ;
21+ private static unsafe delegate * unmanaged [ Cdecl ] < ma_device_ptr , IntPtr , IntPtr , uint , void > deviceDataProc ;
2222 private static Dictionary < UInt64 , IntPtr > audioClipHandles = new Dictionary < UInt64 , IntPtr > ( ) ;
2323 private static AudioBuffer outputBuffer = new AudioBuffer ( 8192 ) ;
2424
@@ -108,8 +108,10 @@ public static void Initialize(UInt32 sampleRate, UInt32 channels, UInt32 periodS
108108
109109 ma_ex_context_config contextConfig = MiniAudioExNative . ma_ex_context_config_init ( sampleRate , ( byte ) channels , periodSizeInFrames , ref pDeviceInfo ) ;
110110
111- deviceDataProc = OnDeviceDataProc ;
112- contextConfig . deviceDataProc = deviceDataProc ;
111+ unsafe
112+ {
113+ deviceDataProc = & OnDeviceDataProc ;
114+ }
113115
114116 audioContext = MiniAudioExNative . ma_ex_context_init ( ref contextConfig ) ;
115117
@@ -228,6 +230,7 @@ internal static bool GetAudioClipHandle(UInt64 hashcode, out IntPtr handle)
228230 return false ;
229231 }
230232
233+ [ UnmanagedCallersOnly ( CallConvs = [ typeof ( System . Runtime . CompilerServices . CallConvCdecl ) ] ) ]
231234 private static void OnDeviceDataProc ( ma_device_ptr pDevice , IntPtr pOutput , IntPtr pInput , UInt32 frameCount )
232235 {
233236 IntPtr pEngine = MiniAudioExNative . ma_ex_device_get_user_data ( pDevice . pointer ) ;
0 commit comments