Exemplo n.º 1
0
        /// <summary>
        ///     Returns information about an audio output device.
        /// </summary>
        /// <param name="deviceIndex">
        ///     Index of the device to be queried. This value must be less than the count returned by
        ///     <see cref="GetDeviceCount" />.
        /// </param>
        /// <param name="deviceDetails"><see cref="DeviceDetails" /> structure.</param>
        /// <returns>HRESULT</returns>
        public unsafe int GetDeviceDetailsNative(int deviceIndex, out DeviceDetails deviceDetails)
        {
            var ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DeviceDetails)));

            try
            {
                deviceDetails = default(DeviceDetails);
                int result = InteropCalls.CallI(UnsafeBasePtr, deviceIndex, ptr.ToPointer(),
                                                ((void **)(*(void **)UnsafeBasePtr))[4]);

                deviceDetails = (DeviceDetails)Marshal.PtrToStructure(ptr, typeof(DeviceDetails));
                return(result);
            }
            finally
            {
                Marshal.FreeHGlobal(ptr);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///     Returns information about an audio output device.
        /// </summary>
        /// <param name="deviceIndex">
        ///     Index of the device to be queried. This value must be less than the count returned by
        ///     <see cref="GetDeviceCount" />.
        /// </param>
        /// <param name="deviceDetails"><see cref="DeviceDetails" /> structure.</param>
        /// <returns>HRESULT</returns>
        public unsafe int GetDeviceDetailsNative(int deviceIndex, out DeviceDetails deviceDetails)
        {
            var ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof (DeviceDetails)));
            try
            {
                deviceDetails = default(DeviceDetails);
                int result = InteropCalls.CallI(UnsafeBasePtr, deviceIndex, ptr.ToPointer(),
                    ((void**) (*(void**) UnsafeBasePtr))[4]);

                deviceDetails = (DeviceDetails) Marshal.PtrToStructure(ptr, typeof (DeviceDetails));
                return result;
            }
            finally
            {
                Marshal.FreeHGlobal(ptr);
            }
        }