internal T GetProperty <T>(ExtendedAudioFilePropertyId id) where T : unmanaged { var unmanagedValueSize = (uint)Marshal.SizeOf(typeof(T)); var unmanagedValue = Marshal.AllocHGlobal((int)unmanagedValueSize); try { SafeNativeMethods.ExtAudioFileGetProperty(_handle, id, ref unmanagedValueSize, unmanagedValue); return(Marshal.PtrToStructure <T>(unmanagedValue)); } finally { Marshal.FreeHGlobal(unmanagedValue); } }
internal void SetProperty <T>(ExtendedAudioFilePropertyId id, T value) where T : unmanaged { var unmanagedValueSize = Marshal.SizeOf(typeof(T)); var unmanagedValue = Marshal.AllocHGlobal(unmanagedValueSize); try { Marshal.StructureToPtr(value, unmanagedValue, false); SafeNativeMethods.ExtAudioFileSetProperty(_handle, id, (uint)unmanagedValueSize, unmanagedValue); } finally { Marshal.FreeHGlobal(unmanagedValue); } }
internal ExtendedAudioFileStatus SetProperty <T>(ExtendedAudioFilePropertyId id, T value) where T : struct { IntPtr unmanagedValue = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(T))); try { Marshal.StructureToPtr(value, unmanagedValue, false); return(SafeNativeMethods.ExtAudioFileSetProperty(_handle, id, (uint)Marshal.SizeOf(typeof(T)), unmanagedValue)); } finally { Marshal.FreeHGlobal(unmanagedValue); } }
internal static extern ExtendedAudioFileStatus ExtAudioFileSetProperty( [NotNull] ExtendedAudioFileHandle handle, ExtendedAudioFilePropertyId id, uint size, IntPtr data);
internal static extern ExtendedAudioFileStatus ExtAudioFileSetProperty(NativeExtendedAudioFileHandle handle, ExtendedAudioFilePropertyId id, UInt32 size, IntPtr data);
internal static extern ExtendedAudioFileStatus ExtAudioFileGetProperty(NativeExtendedAudioFileHandle handle, ExtendedAudioFilePropertyId id, ref uint size, [Out] IntPtr data);