Merge pull request #10405 from JosJuice/android-no-boot-timeout

Android: Get rid of the boot timeout
This commit is contained in:
JMC47 2022-02-23 15:40:54 -05:00 committed by GitHub
commit 75ad057b08
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 27 deletions

View File

@ -84,7 +84,6 @@ std::mutex s_surface_lock;
bool s_need_nonblocking_alert_msg; bool s_need_nonblocking_alert_msg;
Common::Flag s_is_booting; Common::Flag s_is_booting;
bool s_have_wm_user_stop = false;
bool s_game_metadata_is_valid = false; bool s_game_metadata_is_valid = false;
} // Anonymous namespace } // Anonymous namespace
@ -123,7 +122,6 @@ void Host_Message(HostMessageID id)
} }
else if (id == HostMessageID::WMUserStop) else if (id == HostMessageID::WMUserStop)
{ {
s_have_wm_user_stop = true;
if (Core::IsRunning()) if (Core::IsRunning())
Core::QueueHostJob(&Core::Stop); Core::QueueHostJob(&Core::Stop);
} }
@ -553,8 +551,6 @@ static void Run(JNIEnv* env, std::unique_ptr<BootParameters>&& boot, bool riivol
WiimoteReal::InitAdapterClass(); WiimoteReal::InitAdapterClass();
s_have_wm_user_stop = false;
if (riivolution && std::holds_alternative<BootParameters::Disc>(boot->parameters)) if (riivolution && std::holds_alternative<BootParameters::Disc>(boot->parameters))
{ {
const std::string& riivolution_dir = File::GetUserPath(D_RIIVOLUTION_IDX); const std::string& riivolution_dir = File::GetUserPath(D_RIIVOLUTION_IDX);
@ -571,41 +567,25 @@ static void Run(JNIEnv* env, std::unique_ptr<BootParameters>&& boot, bool riivol
s_need_nonblocking_alert_msg = true; s_need_nonblocking_alert_msg = true;
std::unique_lock<std::mutex> surface_guard(s_surface_lock); std::unique_lock<std::mutex> surface_guard(s_surface_lock);
bool successful_boot = BootManager::BootCore(std::move(boot), wsi); if (BootManager::BootCore(std::move(boot), wsi))
if (successful_boot)
{ {
ButtonManager::Init(SConfig::GetInstance().GetGameID()); ButtonManager::Init(SConfig::GetInstance().GetGameID());
static constexpr int TIMEOUT = 10000;
static constexpr int WAIT_STEP = 25; static constexpr int WAIT_STEP = 25;
int time_waited = 0; while (Core::GetState() == Core::State::Starting)
// A Core::CORE_ERROR state would be helpful here.
while (!Core::IsRunningAndStarted())
{
if (time_waited >= TIMEOUT || s_have_wm_user_stop)
{
successful_boot = false;
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_STEP)); std::this_thread::sleep_for(std::chrono::milliseconds(WAIT_STEP));
time_waited += WAIT_STEP;
}
} }
s_is_booting.Clear(); s_is_booting.Clear();
s_need_nonblocking_alert_msg = false; s_need_nonblocking_alert_msg = false;
surface_guard.unlock(); surface_guard.unlock();
if (successful_boot) while (Core::IsRunning())
{ {
while (Core::IsRunningAndStarted()) host_identity_guard.unlock();
{ s_update_main_frame_event.Wait();
host_identity_guard.unlock(); host_identity_guard.lock();
s_update_main_frame_event.Wait(); Core::HostDispatchJobs();
host_identity_guard.lock();
Core::HostDispatchJobs();
}
} }
s_game_metadata_is_valid = false; s_game_metadata_is_valid = false;