From 5a10be7fef3fb0ccc7984272f3c98f5dfaacaa25 Mon Sep 17 00:00:00 2001 From: mathieui Date: Tue, 10 Mar 2015 10:48:25 +0100 Subject: [PATCH] GC Adapter: fix a crash on exit s_detected is better for detecting that a thread is actually running. Also make sure the claim_interface is always called when we detect an adapter. --- Source/Core/Core/HW/SI_GCAdapter.cpp | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Source/Core/Core/HW/SI_GCAdapter.cpp b/Source/Core/Core/HW/SI_GCAdapter.cpp index d2ed8dc96a..a4410881cc 100644 --- a/Source/Core/Core/HW/SI_GCAdapter.cpp +++ b/Source/Core/Core/HW/SI_GCAdapter.cpp @@ -150,15 +150,12 @@ void Setup() { ERROR_LOG(SERIALINTERFACE, "libusb_detach_kernel_driver failed with error: %d", ret); } - else - { - AddGCAdapter(device); - break; - } } - else if ((ret != 0 && ret != LIBUSB_ERROR_NOT_SUPPORTED)) + // this split is needed so that we don't avoid claiming the interface when + // detaching the kernel driver is successful + if (ret != 0) { - ERROR_LOG(SERIALINTERFACE, "libusb_kernel_driver_active error ret = %d", ret); + continue; } else if ((ret = libusb_claim_interface(s_handle, 0))) { @@ -224,7 +221,7 @@ void Shutdown() void Reset() { - if (!SConfig::GetInstance().m_GameCubeAdapter) + if (!s_detected) return; if (s_adapter_thread_running.TestAndClear()) @@ -333,7 +330,7 @@ void Output(int chan, u8 rumble_command) bool IsDetected() { - return s_handle != nullptr; + return s_detected; } bool IsDriverDetected()