diff --git a/Source/OpenTK/Audio/OpenAL/Alc/Alc.cs b/Source/OpenTK/Audio/OpenAL/Alc/Alc.cs index a26c4eac..e7b32528 100644 --- a/Source/OpenTK/Audio/OpenAL/Alc/Alc.cs +++ b/Source/OpenTK/Audio/OpenAL/Alc/Alc.cs @@ -308,12 +308,60 @@ namespace OpenTK.Audio /// This function completes a capture operation, and does not block. /// a pointer to a capture device. - /// a pointer to a buffer buffer, which must be large enough to accommodate samples number of samples. + /// a pointer to a buffer, which must be large enough to accommodate the number of samples. /// the number of samples to be retrieved. [DllImport(Alc.Lib, EntryPoint = "alcCaptureSamples", ExactSpelling = true, CallingConvention = Alc.Style), SuppressUnmanagedCodeSecurity()] - public static extern void CaptureSamples([In] IntPtr device, [Out] out IntPtr buffer, [Out] out int samples); + public static extern void CaptureSamples(IntPtr device, IntPtr buffer, IntPtr samples); // ALC_API void ALC_APIENTRY alcCaptureSamples( ALCdevice *device, ALCvoid *buffer, ALCsizei samples ); + /// This function completes a capture operation, and does not block. + /// a pointer to a capture device. + /// a reference to a buffer, which must be large enough to accommodate the number of samples. + /// the number of samples to be retrieved. + public static void CaptureSamples(IntPtr device, ref T buffer, int samples) + where T : struct + { + GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); + try + { + CaptureSamples(device, handle.AddrOfPinnedObject(), new IntPtr(samples)); + } + finally + { + handle.Free(); + } + } + + /// This function completes a capture operation, and does not block. + /// a pointer to a capture device. + /// a buffer, which must be large enough to accommodate the number of samples. + /// the number of samples to be retrieved. + public static void CaptureSamples(IntPtr device, T[] buffer, int samples) + where T : struct + { + CaptureSamples(device, ref buffer[0], samples); + } + + /// This function completes a capture operation, and does not block. + /// a pointer to a capture device. + /// a buffer, which must be large enough to accommodate the number of samples. + /// the number of samples to be retrieved. + public static void CaptureSamples(IntPtr device, T[,] buffer, int samples) + where T : struct + { + CaptureSamples(device, ref buffer[0, 0], samples); + } + + /// This function completes a capture operation, and does not block. + /// a pointer to a capture device. + /// a buffer, which must be large enough to accommodate the number of samples. + /// the number of samples to be retrieved. + public static void CaptureSamples(IntPtr device, T[,,] buffer, int samples) + where T : struct + { + CaptureSamples(device, ref buffer[0, 0, 0], samples); + } + #endregion Capture functions }