diff options
| author | Léo Lam <leo@innovatetechnologi.es> | 2017-03-26 14:51:12 +0200 |
|---|---|---|
| committer | Léo Lam <leo@innovatetechnologi.es> | 2017-03-26 15:58:30 +0200 |
| commit | 32a1b5068ad61bb025ef28f8bc3bdf81af9bf581 (patch) | |
| tree | 2c78b2386160e9f0bb316e530058abce3192a615 /Source/Core/Common/LibusbContext.cpp | |
| parent | 6c62cfb1aa248d9106f5a70ecf690dd320028365 (diff) | |
Revert "Use a single libusb context"
This reverts commit c8a6dc6c23a5efe99b4bf937003ba3f2f7f8f200.
libusb on Windows isn't really safe to use from different threads
with a single context.
Diffstat (limited to 'Source/Core/Common/LibusbContext.cpp')
| -rw-r--r-- | Source/Core/Common/LibusbContext.cpp | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/Source/Core/Common/LibusbContext.cpp b/Source/Core/Common/LibusbContext.cpp deleted file mode 100644 index 1eb729c4a0..0000000000 --- a/Source/Core/Common/LibusbContext.cpp +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright 2017 Dolphin Emulator Project -// Licensed under GPLv2+ -// Refer to the license.txt file included. - -#include <libusb.h> -#include <memory> -#include <mutex> - -#include "Common/LibusbContext.h" -#include "Common/MsgHandler.h" -#include "Common/StringUtil.h" - -namespace LibusbContext -{ -static std::shared_ptr<libusb_context> s_libusb_context; -static std::once_flag s_context_initialized; - -static libusb_context* Create() -{ - libusb_context* context; - const int ret = libusb_init(&context); - if (ret < LIBUSB_SUCCESS) - { - bool is_windows = false; -#ifdef _WIN32 - is_windows = true; -#endif - const std::string reason = - is_windows && ret == LIBUSB_ERROR_NOT_FOUND ? - GetStringT("Failed to initialize libusb because usbdk is not installed.") : - StringFromFormat(GetStringT("Failed to initialize libusb (%s).").c_str(), - libusb_error_name(ret)); - PanicAlertT("%s\nSome USB features will not work.", reason.c_str()); - return nullptr; - } - return context; -} - -std::shared_ptr<libusb_context> Get() -{ - std::call_once(s_context_initialized, []() { - s_libusb_context.reset(Create(), [](auto* context) { - if (context != nullptr) - libusb_exit(context); - }); - }); - return s_libusb_context; -} -} |
