Make sure that WiimoteReal is really shutdown on app exit. Particulary

ensure that the wiimote scanning thread is joined.  This fixes a crash
on shutdown if scanning has been initiated.
This commit is contained in:
Glenn Rice 2013-07-31 09:09:18 -05:00
parent 44d17b5da5
commit 01987be6b9
3 changed files with 6 additions and 8 deletions

View File

@ -32,7 +32,7 @@ void Shutdown()
delete *i; delete *i;
g_plugin.controllers.clear(); g_plugin.controllers.clear();
WiimoteReal::Shutdown(); WiimoteReal::Stop();
g_controller_interface.Shutdown(); g_controller_interface.Shutdown();
} }

View File

@ -54,6 +54,7 @@ namespace WiimoteReal
{ {
void Initialize(bool wait = false); void Initialize(bool wait = false);
void Stop();
void Shutdown(); void Shutdown();
void Resume(); void Resume();
void Pause(); void Pause();

View File

@ -570,15 +570,15 @@ void Initialize(bool wait)
g_real_wiimotes_initialized = true; g_real_wiimotes_initialized = true;
} }
void Shutdown(void) void Stop(void)
{ {
for (unsigned int i = 0; i < MAX_BBMOTES; ++i) for (unsigned int i = 0; i < MAX_BBMOTES; ++i)
if (g_wiimotes[i] && g_wiimotes[i]->IsConnected()) if (g_wiimotes[i] && g_wiimotes[i]->IsConnected())
g_wiimotes[i]->EmuStop(); g_wiimotes[i]->EmuStop();
}
// WiimoteReal is shutdown on app exit void Shutdown(void)
return; {
g_wiimote_scanner.StopScanning(); g_wiimote_scanner.StopScanning();
std::lock_guard<std::recursive_mutex> lk(g_refresh_lock); std::lock_guard<std::recursive_mutex> lk(g_refresh_lock);
@ -589,9 +589,6 @@ void Shutdown(void)
NOTICE_LOG(WIIMOTE, "WiimoteReal::Shutdown"); NOTICE_LOG(WIIMOTE, "WiimoteReal::Shutdown");
g_real_wiimotes_initialized = false; g_real_wiimotes_initialized = false;
for (unsigned int i = 0; i < MAX_BBMOTES; ++i)
HandleWiimoteDisconnect(i);
} }
void Resume() void Resume()