コード例 #1
0
ファイル: XAudio2_7.cs プロジェクト: werlon/cscore
        /// <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);
            }
        }
コード例 #2
0
ファイル: XAudio2_7.cs プロジェクト: hoangduit/cscore
        /// <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);
            }
        }