Open Lighting Architecture: ola::plugin::usbdmx::ThreadedUsbSender Class Reference

| Open Lighting Architecture 0.10.9

Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | List of all members
ola::plugin::usbdmx::ThreadedUsbSender Class Referenceabstract

## Detailed Description

Send DMX data using libusb, from a separate thread.

The synchronous libusb calls can sometimes take a while to complete, I've seen cases of up to 21ms.

To avoid blocking the main thread, we need to perform the libusb transfer calls in a separate thread. This class contains all the thread management code, leaving the subclass to implement TransmitBuffer(), which performs the actual transfer.

ThreadedUsbSender can be used as a building block for synchronous widgets.

Inheritance diagram for ola::plugin::usbdmx::ThreadedUsbSender:

## Public Member Functions
| ThreadedUsbSender (libusb_device *usb_device, libusb_device_handle *usb_handle, int interface_number=0)
| Create a new ThreadedUsbSender.
bool | Start ()
| Start the new thread.
void * | Run ()
| Entry point for the new thread.
bool | SendDMX (const DmxBuffer &buffer)
| Buffer a DMX frame for sending.

## Protected Member Functions
virtual bool | TransmitBuffer (libusb_device_handle *handle, const DmxBuffer &buffer)=0
| Perform the DMX transfer.

## Constructor & Destructor Documentation

## ◆ ThreadedUsbSender()

ola::plugin::usbdmx::ThreadedUsbSender::ThreadedUsbSender | ( | libusb_device * | usb_device,
|  | libusb_device_handle * | usb_handle,
|  | int | interface_number = 0 )

Create a new ThreadedUsbSender.

Parameters

  usb_device | The usb_device to use. The ThreadedUsbSender takes a ref on the device, while the ThreadedUsbSender object exists.
  usb_handle | The handle to use for the DMX transfer.
  interface_number | the USB interface number of the widget. Defaults to 0.

## Member Function Documentation

## ◆ Run()

void * ola::plugin::usbdmx::ThreadedUsbSender::Run | ( |  | ) |
| virtual

Entry point for the new thread.

Returns
  NULL.

Implements ola::thread::Thread.

## ◆ SendDMX()

bool ola::plugin::usbdmx::ThreadedUsbSender::SendDMX | ( | const DmxBuffer & | buffer | ) |

Buffer a DMX frame for sending.

Parameters

  buffer | the DmxBuffer to send.

This should be called in the main thread.

## ◆ Start()

bool ola::plugin::usbdmx::ThreadedUsbSender::Start | ( |  | ) |
| virtual

Start the new thread.

Returns
  true if the thread is running, false otherwise.

Reimplemented from ola::thread::Thread.

## ◆ TransmitBuffer()

virtual bool ola::plugin::usbdmx::ThreadedUsbSender::TransmitBuffer | ( | libusb_device_handle * | handle,
|  | const DmxBuffer & | buffer )
| protectedpure virtual

Perform the DMX transfer.

Parameters

  handle | the libusb_device_handle to use for the transfer.
  buffer | The DmxBuffer to transfer.

Returns
  true if the transfer was completed, false otherwise.

This is called from the sender thread.

The documentation for this class was generated from the following files:

- plugins/usbdmx/ThreadedUsbSender.h
- plugins/usbdmx/ThreadedUsbSender.cpp