Use separate libusb contexts to avoid thread safety issues

Unfortunately, it appears that using libusb's synchronous transfer API
from several threads causes nasty race conditions in event handling and
can lead to deadlocks, despite the fact that libusb's synchronous API
is documented to be perfectly fine to use from several threads (only
the manual polling functionality is supposed to require special
precautions).

Since usbdk was the only real reason for using a single libusb context
and since usbdk (currently) has so many issues with Dolphin, I think
dropping support for it in order to fix other backends is acceptable.
This commit is contained in:
Léo Lam 2019-06-25 17:31:35 +02:00
parent 769ba43abf
commit cf60a9a7f7
8 changed files with 16 additions and 26 deletions

View file

@ -109,12 +109,6 @@ bool Context::GetDeviceList(GetDeviceListCallback callback)
return m_impl->GetDeviceList(std::move(callback));
}
Context& GetContext()
{
static Context s_context;
return s_context;
}
ConfigDescriptor MakeConfigDescriptor(libusb_device* device, u8 config_num)
{
#if defined(__LIBUSB__)