Example #1
0
        /// <summary>
        /// Completes a capture operation. This call does not block.
        /// </summary>
        /// <typeparam name="TManagedFormat">The managed format of the buffer.</typeparam>
        /// <typeparam name="TBufferFormat">The format of the native buffer.</typeparam>
        /// <param name="device">The device.</param>
        /// <param name="bufferFormat">The data format of the buffer.</param>
        /// <param name="sampleCount">The number of samples to retrieve.</param>
        /// <returns>The captured samples.</returns>
        public unsafe TManagedFormat[] CaptureSamples <TManagedFormat, TBufferFormat>
        (
            Device *device,
            TBufferFormat bufferFormat,
            int sampleCount
        )
            where TBufferFormat : struct, Enum
            where TManagedFormat : unmanaged
        {
            var formatSize = FormatHelpers.GetFormatSize(bufferFormat);

            var managedFormatSize         = sizeof(TManagedFormat);
            var internalBufferSize        = sampleCount * formatSize;
            var managedBufferElementCount = internalBufferSize / managedFormatSize;

            var resizeBuffer = new TManagedFormat[managedBufferElementCount];

            CaptureSamples(device, bufferFormat, sampleCount, in resizeBuffer);

            return(resizeBuffer);
        }