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

@ -38,11 +38,6 @@ private:
std::unique_ptr<Impl> m_impl;
};
// Use this to get a libusb context. Do *not* use any other context
// because some libusb backends such as UsbDk only work properly with a single context.
// Additionally, device lists must be retrieved using GetDeviceList for thread safety reasons.
Context& GetContext();
using ConfigDescriptor = UniquePtr<libusb_config_descriptor>;
ConfigDescriptor MakeConfigDescriptor(libusb_device* device, u8 config_num = 0);
} // namespace LibusbUtils