Merge pull request #9086 from JosJuice/wiimote-init-order
Core: Run Wiimote::Initialize before HW::Init to avoid crash
This commit is contained in:
commit
e4e50691fb
|
@ -436,54 +436,6 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi
|
||||||
DeclareAsCPUThread();
|
DeclareAsCPUThread();
|
||||||
s_frame_step = false;
|
s_frame_step = false;
|
||||||
|
|
||||||
Movie::Init(*boot);
|
|
||||||
Common::ScopeGuard movie_guard{&Movie::Shutdown};
|
|
||||||
|
|
||||||
HW::Init();
|
|
||||||
|
|
||||||
Common::ScopeGuard hw_guard{[] {
|
|
||||||
// We must set up this flag before executing HW::Shutdown()
|
|
||||||
s_hardware_initialized = false;
|
|
||||||
INFO_LOG(CONSOLE, "%s", StopMessage(false, "Shutting down HW").c_str());
|
|
||||||
HW::Shutdown();
|
|
||||||
INFO_LOG(CONSOLE, "%s", StopMessage(false, "HW shutdown").c_str());
|
|
||||||
|
|
||||||
// Clear on screen messages that haven't expired
|
|
||||||
OSD::ClearMessages();
|
|
||||||
|
|
||||||
// The config must be restored only after the whole HW has shut down,
|
|
||||||
// not when it is still running.
|
|
||||||
BootManager::RestoreConfig();
|
|
||||||
|
|
||||||
PatchEngine::Shutdown();
|
|
||||||
HLE::Clear();
|
|
||||||
}};
|
|
||||||
|
|
||||||
VideoBackendBase::PopulateBackendInfo();
|
|
||||||
|
|
||||||
if (!g_video_backend->Initialize(wsi))
|
|
||||||
{
|
|
||||||
PanicAlert("Failed to initialize video backend!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Common::ScopeGuard video_guard{[] { g_video_backend->Shutdown(); }};
|
|
||||||
|
|
||||||
// Render a single frame without anything on it to clear the screen.
|
|
||||||
// This avoids the game list being displayed while the core is finishing initializing.
|
|
||||||
g_renderer->BeginUIFrame();
|
|
||||||
g_renderer->EndUIFrame();
|
|
||||||
|
|
||||||
if (cpu_info.HTT)
|
|
||||||
SConfig::GetInstance().bDSPThread = cpu_info.num_cores > 4;
|
|
||||||
else
|
|
||||||
SConfig::GetInstance().bDSPThread = cpu_info.num_cores > 2;
|
|
||||||
|
|
||||||
if (!DSP::GetDSPEmulator()->Initialize(core_parameter.bWii, core_parameter.bDSPThread))
|
|
||||||
{
|
|
||||||
PanicAlert("Failed to initialize DSP emulation!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The frontend will likely have initialized the controller interface, as it needs
|
// The frontend will likely have initialized the controller interface, as it needs
|
||||||
// it to provide the configuration dialogs. In this case, instead of re-initializing
|
// it to provide the configuration dialogs. In this case, instead of re-initializing
|
||||||
// entirely, we switch the window used for inputs to the render window. This way, the
|
// entirely, we switch the window used for inputs to the render window. This way, the
|
||||||
|
@ -542,6 +494,54 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi
|
||||||
g_controller_interface.Shutdown();
|
g_controller_interface.Shutdown();
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
Movie::Init(*boot);
|
||||||
|
Common::ScopeGuard movie_guard{&Movie::Shutdown};
|
||||||
|
|
||||||
|
HW::Init();
|
||||||
|
|
||||||
|
Common::ScopeGuard hw_guard{[] {
|
||||||
|
// We must set up this flag before executing HW::Shutdown()
|
||||||
|
s_hardware_initialized = false;
|
||||||
|
INFO_LOG(CONSOLE, "%s", StopMessage(false, "Shutting down HW").c_str());
|
||||||
|
HW::Shutdown();
|
||||||
|
INFO_LOG(CONSOLE, "%s", StopMessage(false, "HW shutdown").c_str());
|
||||||
|
|
||||||
|
// Clear on screen messages that haven't expired
|
||||||
|
OSD::ClearMessages();
|
||||||
|
|
||||||
|
// The config must be restored only after the whole HW has shut down,
|
||||||
|
// not when it is still running.
|
||||||
|
BootManager::RestoreConfig();
|
||||||
|
|
||||||
|
PatchEngine::Shutdown();
|
||||||
|
HLE::Clear();
|
||||||
|
}};
|
||||||
|
|
||||||
|
VideoBackendBase::PopulateBackendInfo();
|
||||||
|
|
||||||
|
if (!g_video_backend->Initialize(wsi))
|
||||||
|
{
|
||||||
|
PanicAlert("Failed to initialize video backend!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Common::ScopeGuard video_guard{[] { g_video_backend->Shutdown(); }};
|
||||||
|
|
||||||
|
// Render a single frame without anything on it to clear the screen.
|
||||||
|
// This avoids the game list being displayed while the core is finishing initializing.
|
||||||
|
g_renderer->BeginUIFrame();
|
||||||
|
g_renderer->EndUIFrame();
|
||||||
|
|
||||||
|
if (cpu_info.HTT)
|
||||||
|
SConfig::GetInstance().bDSPThread = cpu_info.num_cores > 4;
|
||||||
|
else
|
||||||
|
SConfig::GetInstance().bDSPThread = cpu_info.num_cores > 2;
|
||||||
|
|
||||||
|
if (!DSP::GetDSPEmulator()->Initialize(core_parameter.bWii, core_parameter.bDSPThread))
|
||||||
|
{
|
||||||
|
PanicAlert("Failed to initialize DSP emulation!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
AudioCommon::InitSoundStream();
|
AudioCommon::InitSoundStream();
|
||||||
Common::ScopeGuard audio_guard{&AudioCommon::ShutdownSoundStream};
|
Common::ScopeGuard audio_guard{&AudioCommon::ShutdownSoundStream};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue