Exemplo n.º 1
0
        /// <summary>
        /// Allocate a libusb transfer with a specified number of isochronous packet descriptors
        /// </summary>
        /// <remarks>
        /// <para>The returned transfer is pre-initialized for you. When the new transfer is no longer needed, it should be freed with <see cref="Free"/>.</para>
        /// <para>Transfers intended for non-isochronous endpoints (e.g. control, bulk, interrupt) should specify an iso_packets count of zero.</para>
        /// <para>For transfers intended for isochronous endpoints, specify an appropriate number of packet descriptors to be allocated as part of the transfer. The returned transfer is not specially initialized for isochronous I/O; you are still required to set the <see cref="MonoUsbTransfer.NumIsoPackets"/> and <see cref="MonoUsbTransfer.Type"/> fields accordingly.</para>
        /// <para>It is safe to allocate a transfer with some isochronous packets and then use it on a non-isochronous endpoint. If you do this, ensure that at time of submission, <see cref="MonoUsbTransfer.NumIsoPackets"/> is 0 and that type is set appropriately.</para>
        /// <note title="Libusb-1.0 API Note:" type="cpp">
        /// <see cref="Alloc"/> is roughly equivalent to
        /// <a href="http://libusb.sourceforge.net/api-1.0/group__asyncio.html#ga13cc69ea40c702181c430c950121c000">libusb_alloc_transfer()</a>.
        /// </note>
        /// </remarks>
        /// <param name="numIsoPackets">number of isochronous packet descriptors to allocate.</param>
        /// <returns>A newly allocated <see cref="MonoUsbTransfer"/>.</returns>
        /// <exception cref="OutOfMemoryException">If the transfer was not allocated.</exception>
        public static MonoUsbTransfer Alloc(int numIsoPackets)
        {
            IntPtr p = MonoUsbApi.AllocTransfer(numIsoPackets);

            if (p == IntPtr.Zero)
            {
                throw new OutOfMemoryException("AllocTransfer");
            }
            return(new MonoUsbTransfer(p));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Allocate a libusb transfer with a specified number of isochronous packet descriptors
 /// </summary>
 /// <remarks>
 /// <para>The transfer is pre-initialized for you. When the new transfer is no longer needed, it should be freed with <see cref="Free"/>.</para>
 /// <para>Transfers intended for non-isochronous endpoints (e.g. control, bulk, interrupt) should specify an iso_packets count of zero.</para>
 /// <para>For transfers intended for isochronous endpoints, specify an appropriate number of packet descriptors to be allocated as part of the transfer. The returned transfer is not specially initialized for isochronous I/O; you are still required to set the <see cref="MonoUsbTransfer.NumIsoPackets"/> and <see cref="MonoUsbTransfer.Type"/> fields accordingly.</para>
 /// <para>It is safe to allocate a transfer with some isochronous packets and then use it on a non-isochronous endpoint. If you do this, ensure that at time of submission, <see cref="MonoUsbTransfer.NumIsoPackets"/> is 0 and that type is set appropriately.</para>
 /// </remarks>
 /// <param name="numIsoPackets">number of isochronous packet descriptors to allocate.</param>
 public MonoUsbTransfer(int numIsoPackets)
 {
     handle = MonoUsbApi.AllocTransfer(numIsoPackets);
 }