예제 #1
0
        /// <summary>
        /// Convenience function to locate the position of an isochronous packet within the buffer of an isochronous transfer, for transfers where each packet is of identical size.
        /// </summary>
        /// <remarks>
        /// <para>This function relies on the assumption that every packet within the transfer is of identical size to the first packet. Calculating the location of the packet buffer is then just a simple calculation: buffer + (packet_size * packet)</para>
        /// <para>Do not use this function on transfers other than those that have identical packet lengths for each packet.</para>
        /// <note title="Libusb-1.0 API Note:" type="cpp">
        /// <see cref="GetIsoPacketBufferSimple"/> is roughly equivalent to
        /// <a href="http://libusb.sourceforge.net/api-1.0/group__asyncio.html#ga3df9a28c4f5c8f1850181ddb5efd12fd">libusb_get_iso_packet_buffer_simple()</a>.
        /// </note>
        /// </remarks>
        /// <param name="packet">The packet to return the address of.</param>
        /// <returns>the base address of the packet buffer inside the transfer buffer.</returns>
        /// <exception cref="ArgumentOutOfRangeException">This exception is thrown if the packet requested is >= <see cref="NumIsoPackets"/>.</exception>
        public IntPtr GetIsoPacketBufferSimple(int packet)
        {
            if (packet >= NumIsoPackets)
            {
                throw new ArgumentOutOfRangeException("packet", "GetIsoPacketBufferSimple: packet must be < NumIsoPackets");
            }

            return(new IntPtr((PtrBuffer.ToInt64() + (IsoPacket(0).Length *packet))));
        }
예제 #2
0
        /// <summary>
        /// Convenience function to locate the position of an isochronous packet within the buffer of an isochronous transfer.
        /// </summary>
        /// <remarks>
        /// <para>This is a thorough function which loops through all preceding packets, accumulating their lengths to find the position of the specified packet. Typically you will assign equal lengths to each packet in the transfer, and hence the above method is sub-optimal. You may wish to use <see cref="GetIsoPacketBufferSimple"/> instead.</para>
        /// <note title="Libusb-1.0 API Note:" type="cpp">
        /// <see cref="GetIsoPacketBuffer"/> is roughly equivalent to
        /// <a href="http://libusb.sourceforge.net/api-1.0/group__asyncio.html#ga7f6ea0eb35a216d19d984977e454a7b3">libusb_get_iso_packet_buffer()</a>.
        /// </note>
        /// </remarks>
        /// <param name="packet">The packet to return the address of.</param>
        /// <returns>the base address of the packet buffer inside the transfer buffer.</returns>
        /// <exception cref="ArgumentOutOfRangeException">This exception is thrown if the packet requested is >= <see cref="NumIsoPackets"/>.</exception>
        public IntPtr GetIsoPacketBuffer(int packet)
        {
            if (packet >= NumIsoPackets)
            {
                throw new ArgumentOutOfRangeException("packet", "GetIsoPacketBuffer: packet must be < NumIsoPackets");
            }
            long offset = PtrBuffer.ToInt64();

            for (int i = 0; i < packet; i++)
            {
                offset += IsoPacket(i).Length;
            }

            return(new IntPtr(offset));
        }