using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System; namespace Raylib_cs; /// /// Audio stream processor. /// Used with /// and /// public delegate void AudioCallback(Span buffer); internal static unsafe class AudioMixed { public static AudioCallback Callback = null; [UnmanagedCallersOnly(CallConvs = new Type[] { typeof(CallConvCdecl) })] public static void Processor(void* buffer, uint frames) { // The buffer is stereo audio, so we need to double our frame count. frames = Math.Min(frames * 2, int.MaxValue); Span floats = new(buffer, (int)frames); Callback?.Invoke(floats); } }