21 #ifndef PLUGINS_USBDMX_ASYNCPLUGINIMPL_H_
22 #define PLUGINS_USBDMX_ASYNCPLUGINIMPL_H_
33 #include "ola/thread/Mutex.h"
34 #include "ola/thread/Thread.h"
35 #include "plugins/usbdmx/PluginImplInterface.h"
36 #include "plugins/usbdmx/SyncronizedWidgetObserver.h"
37 #include "plugins/usbdmx/WidgetFactory.h"
46 #if defined(LIBUSB_API_VERSION) && (LIBUSB_API_VERSION >= 0x01000102)
47 #define OLA_LIBUSB_HAS_HOTPLUG_API
65 unsigned int debug_level);
71 #ifdef OLA_LIBUSB_HAS_HOTPLUG_API
82 void HotPlugEvent(
struct libusb_device *dev,
83 libusb_hotplug_event event);
99 typedef std::vector<class WidgetFactory*> WidgetFactories;
100 typedef std::map<struct libusb_device*, WidgetFactory*> USBDeviceToFactoryMap;
101 typedef std::map<class Widget*, Device*> WidgetToDeviceMap;
102 typedef std::pair<uint8_t, uint8_t> USBDeviceID;
103 typedef std::map<USBDeviceID, struct libusb_device*> USBDeviceIDs;
107 const unsigned int m_debug_level;
111 libusb_context *m_context;
114 bool m_suppress_hotplug_events;
115 std::auto_ptr<class LibUsbThread> m_usb_thread;
116 std::auto_ptr<class LibUsbAdaptor> m_usb_adaptor;
118 WidgetFactories m_widget_factories;
119 USBDeviceToFactoryMap m_device_factory_map;
120 WidgetToDeviceMap m_widget_device_map;
124 USBDeviceIDs m_seen_usb_devices;
126 bool HotplugSupported();
127 bool USBDeviceAdded(libusb_device *device);
128 void USBDeviceRemoved(libusb_device *device);
130 bool StartAndRegisterDevice(
class Widget *widget,
Device *device);
131 void RemoveWidget(
class Widget *widget);
133 bool ScanUSBDevices();
140 #endif // PLUGINS_USBDMX_ASYNCPLUGINIMPL_H_