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.
This commit is contained in:
mathieui 2015-03-10 10:48:25 +01:00
parent ebedc80545
commit 5a10be7fef
1 changed files with 6 additions and 9 deletions

View File

@ -150,15 +150,12 @@ void Setup()
{ {
ERROR_LOG(SERIALINTERFACE, "libusb_detach_kernel_driver failed with error: %d", ret); 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))) else if ((ret = libusb_claim_interface(s_handle, 0)))
{ {
@ -224,7 +221,7 @@ void Shutdown()
void Reset() void Reset()
{ {
if (!SConfig::GetInstance().m_GameCubeAdapter) if (!s_detected)
return; return;
if (s_adapter_thread_running.TestAndClear()) if (s_adapter_thread_running.TestAndClear())
@ -333,7 +330,7 @@ void Output(int chan, u8 rumble_command)
bool IsDetected() bool IsDetected()
{ {
return s_handle != nullptr; return s_detected;
} }
bool IsDriverDetected() bool IsDriverDetected()