1
0
mirror of https://github.com/dolphin-emu/dolphin synced 2024-07-01 07:54:33 +00:00

Compare commits

..

2 Commits

Author SHA1 Message Date
LillyJadeKatrin
37a9019bca
Merge 917d32d921 into 10a95a4d5b 2024-06-25 20:47:13 -04:00
LillyJadeKatrin
917d32d921 Handle Pausing in AchievementManager
There are two pieces of functionality to be added here. One, we want to disallow pausing too frequently, as it may be used as an artificial slowdown. This is handled within the client, which can tell us if a pause is allowed. Two, we want to call rc_client_idle on a periodic basis so the connection with the server can be maintained even while the emulator is paused.
2024-06-25 20:36:20 -04:00

View File

@ -269,16 +269,20 @@ bool AchievementManager::CanPause()
void AchievementManager::DoIdle()
{
std::thread([]() {
while (Core::GetState(*AchievementManager::GetInstance().m_system) == Core::State::Paused &&
AchievementManager::GetInstance().m_background_execution_allowed)
std::thread([this]() {
while (true)
{
Common::SleepCurrentThread(1000);
std::lock_guard lg{AchievementManager::GetInstance().m_lock};
auto* client = AchievementManager::GetInstance().m_client;
if (!client || !AchievementManager::GetInstance().IsGameLoaded())
std::lock_guard lg{m_lock};
if (!m_system || Core::GetState(*m_system) != Core::State::Paused)
return;
rc_client_idle(client);
if (!m_background_execution_allowed)
return;
Core::QueueHostJob([this](Core::System& system) {
if (!m_client || !IsGameLoaded())
return;
rc_client_idle(m_client);
});
}
}).detach();
}