Beispiel #1
0
        private void allocTransfer(UsbEndpointBase endpointBase, bool ownsTransfer, int isoPacketSize, int count)
        {
            int numIsoPackets = 0;

            if (isoPacketSize > 0)
            {
                numIsoPackets = count / isoPacketSize;
            }
            freeTransfer();
            mTransfer               = MonoUsbTransfer.Alloc(numIsoPackets);
            mOwnsTransfer           = ownsTransfer;
            mTransfer.Type          = endpointBase.Type;
            mTransfer.Endpoint      = endpointBase.EpNum;
            mTransfer.NumIsoPackets = numIsoPackets;

            if (!mCompleteEventHandle.IsAllocated)
            {
                mCompleteEventHandle = GCHandle.Alloc(mTransferCompleteEvent);
            }
            mTransfer.PtrUserData = GCHandle.ToIntPtr(mCompleteEventHandle);

            if (numIsoPackets > 0)
            {
                mTransfer.SetIsoPacketLengths(isoPacketSize);
            }
        }
        private void allocTransfer(UsbEndpointBase endpointBase, bool ownsTransfer, int isoPacketSize, int count)
        {
            int numIsoPackets = 0;

            // Patch for using libusb-1.0 on windows with libusbwK.sys
            EndpointType endpointType = endpointBase.Type;

            if (UsbDevice.IsLinux)
            {
                if (isoPacketSize > 0)
                {
                    numIsoPackets = count / isoPacketSize;
                }
            }
            else
            {
                if (endpointType == EndpointType.Isochronous)
                {
                    endpointType = EndpointType.Bulk;
                }
            }
            ///////////////////////////////////////////////////////////////

            freeTransfer();
            mTransfer               = MonoUsbTransfer.Alloc(numIsoPackets);
            mOwnsTransfer           = ownsTransfer;
            mTransfer.Type          = endpointType;
            mTransfer.Endpoint      = endpointBase.EpNum;
            mTransfer.NumIsoPackets = numIsoPackets;

            if (!mCompleteEventHandle.IsAllocated)
            {
                mCompleteEventHandle = GCHandle.Alloc(mTransferCompleteEvent);
            }
            mTransfer.PtrUserData = GCHandle.ToIntPtr(mCompleteEventHandle);


            if (numIsoPackets > 0)
            {
                mTransfer.SetIsoPacketLengths(isoPacketSize);
            }
        }