static AudioConverterStatus SetConverterProperty <T>(IntPtr converter, AudioConverterPropertyId propertyId, T value) where T : struct
        {
            Contract.Requires(converter != IntPtr.Zero);

            IntPtr unmanagedValue = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(T)));

            try
            {
                Marshal.StructureToPtr(value, unmanagedValue, false);
                return(SafeNativeMethods.AudioConverterSetProperty(converter, propertyId, (uint)Marshal.SizeOf(typeof(T)), unmanagedValue));
            }
            finally
            {
                Marshal.FreeHGlobal(unmanagedValue);
            }
        }
Exemple #2
0
        static void SetConverterProperty <T>(IntPtr converter, AudioConverterPropertyId propertyId, T value)
            where T : struct
        {
            var unmanagedValueSize = Marshal.SizeOf(typeof(T));
            var unmanagedValue     = Marshal.AllocHGlobal(unmanagedValueSize);

            try
            {
                Marshal.StructureToPtr(value, unmanagedValue, false);
                SafeNativeMethods.AudioConverterSetProperty(converter, propertyId, (uint)unmanagedValueSize,
                                                            unmanagedValue);
            }
            finally
            {
                Marshal.FreeHGlobal(unmanagedValue);
            }
        }
 internal static extern AudioConverterStatus AudioConverterSetProperty(
     IntPtr handle,
     AudioConverterPropertyId id,
     uint size,
     IntPtr data);
 internal AudioConverterStatus SetProperty(AudioConverterPropertyId propertyId, uint size, IntPtr data)
 {
     return(SafeNativeMethods.AudioConverterSetProperty(_handle, propertyId, size, data));
 }
 internal void SetProperty(AudioConverterPropertyId propertyId, uint size, IntPtr data) =>
 SafeNativeMethods.AudioConverterSetProperty(_handle, propertyId, size, data);