Method: LIBUSB::DevHandle#alloc_streams

Defined in:
lib/libusb/dev_handle.rb,
lib/libusb/dev_handle.rb
more...

#alloc_streams(num_streams, endpoints) ⇒ Fixnum

Allocate up to num_streams usb bulk streams on the specified endpoints. This function takes an array of endpoints rather then a single endpoint because some protocols require that endpoints are setup with similar stream ids. All endpoints passed in must belong to the same interface.

Note this function may return less streams then requested. Also note that the same number of streams are allocated for each endpoint in the endpoint array.

Stream id 0 is reserved, and should not be used to communicate with devices. If #alloc_streams returns with a value of N, you may use stream ids 1 to N.

Available since libusb-1.0.19.

Parameters:

  • num_streams (Fixnum)

    number of streams to try to allocate

  • endpoints (Array<Fixnum>, Array<Endpoint>)

    array of endpoints to allocate streams on

Returns:

  • (Fixnum)

    number of streams allocated

Raises:

  • (NotImplementedError)

See Also:

[View source]

218
219
220
221
222
223
# File 'lib/libusb/dev_handle.rb', line 218

def alloc_streams(num_streams, endpoints)
  pEndpoints = endpoints_as_ffi_bytes(endpoints)
  res = Call.libusb_alloc_streams(@pHandle, num_streams, pEndpoints, endpoints.length)
  LIBUSB.raise_error res, "in libusb_alloc_streams" unless res>=0
  res
end