forked from len0rd/rockbox
qeditor: initialise libusb once in a static ctor
Change-Id: Ic93def2b3633c498c9863b0dada3281853be8c6c Reviewed-on: http://gerrit.rockbox.org/973 Reviewed-by: Amaury Pouly <amaury.pouly@gmail.com>
This commit is contained in:
parent
7d112053ab
commit
b2ef4a806b
1 changed files with 18 additions and 5 deletions
|
|
@ -356,7 +356,6 @@ bool HWStubIoBackend::Reload()
|
||||||
*/
|
*/
|
||||||
HWStubBackendHelper::HWStubBackendHelper()
|
HWStubBackendHelper::HWStubBackendHelper()
|
||||||
{
|
{
|
||||||
libusb_init(NULL);
|
|
||||||
#ifdef LIBUSB_NO_HOTPLUG
|
#ifdef LIBUSB_NO_HOTPLUG
|
||||||
m_hotplug = false;
|
m_hotplug = false;
|
||||||
#else
|
#else
|
||||||
|
|
@ -371,7 +370,7 @@ HWStubBackendHelper::HWStubBackendHelper()
|
||||||
&HWStubBackendHelper::HotPlugCallback, reinterpret_cast< void* >(this),
|
&HWStubBackendHelper::HotPlugCallback, reinterpret_cast< void* >(this),
|
||||||
&m_hotplug_handle);
|
&m_hotplug_handle);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* LIBUSB_NO_HOTPLUG */
|
||||||
}
|
}
|
||||||
|
|
||||||
HWStubBackendHelper::~HWStubBackendHelper()
|
HWStubBackendHelper::~HWStubBackendHelper()
|
||||||
|
|
@ -379,7 +378,7 @@ HWStubBackendHelper::~HWStubBackendHelper()
|
||||||
#ifndef LIBUSB_NO_HOTPLUG
|
#ifndef LIBUSB_NO_HOTPLUG
|
||||||
if(m_hotplug)
|
if(m_hotplug)
|
||||||
libusb_hotplug_deregister_callback(NULL, m_hotplug_handle);
|
libusb_hotplug_deregister_callback(NULL, m_hotplug_handle);
|
||||||
#endif
|
#endif /* LIBUSB_NO_HOTPLUG */
|
||||||
}
|
}
|
||||||
|
|
||||||
QList< HWStubDevice* > HWStubBackendHelper::GetDevList()
|
QList< HWStubDevice* > HWStubBackendHelper::GetDevList()
|
||||||
|
|
@ -420,14 +419,28 @@ int HWStubBackendHelper::HotPlugCallback(struct libusb_context *ctx, struct libu
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* LIBUSB_NO_HOTPLUG */
|
||||||
|
|
||||||
bool HWStubBackendHelper::HasHotPlugSupport()
|
bool HWStubBackendHelper::HasHotPlugSupport()
|
||||||
{
|
{
|
||||||
return m_hotplug;
|
return m_hotplug;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
namespace
|
||||||
|
{
|
||||||
|
class lib_usb_init
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
lib_usb_init()
|
||||||
|
{
|
||||||
|
libusb_init(NULL);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
lib_usb_init __lib_usb_init;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* HAVE_HWSTUB */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* BackendHelper
|
* BackendHelper
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue