Merge pull request #12695 from mitaclaw/core-global-system-4
Core::IsRunning: Avoid Global System Accessor
This commit is contained in:
25 files changed
+90
-74
No files matched your search
@@ -27,12 +27,13 @@
|
||||
#include "Core/IOS/IOS.h"
|
||||
#include "Core/IOS/USB/Bluetooth/BTBase.h"
|
||||
#include "Core/SysConf.h"
|
||||
#include "Core/System.h"
|
||||
|
||||
namespace ConfigLoaders
|
||||
{
|
||||
void SaveToSYSCONF(Config::LayerType layer, std::function<bool(const Config::Location&)> predicate)
|
||||
{
|
||||
if (Core::IsRunning())
|
||||
if (Core::IsRunning(Core::System::GetInstance()))
|
||||
return;
|
||||
|
||||
IOS::HLE::Kernel ios;
|
||||
@@ -182,7 +183,7 @@ public:
|
||||
private:
|
||||
void LoadFromSYSCONF(Config::Layer* layer)
|
||||
{
|
||||
if (Core::IsRunning())
|
||||
if (Core::IsRunning(Core::System::GetInstance()))
|
||||
return;
|
||||
|
||||
IOS::HLE::Kernel ios;
|
||||
|
||||
@@ -188,7 +188,7 @@ void SConfig::SetRunningGameMetadata(const std::string& game_id, const std::stri
|
||||
m_title_description = title_database.Describe(m_gametdb_id, language);
|
||||
NOTICE_LOG_FMT(CORE, "Active title: {}", m_title_description);
|
||||
Host_TitleChanged();
|
||||
if (Core::IsRunning())
|
||||
if (Core::IsRunning(system))
|
||||
{
|
||||
Core::UpdateTitle(system);
|
||||
}
|
||||
@@ -196,16 +196,16 @@ void SConfig::SetRunningGameMetadata(const std::string& game_id, const std::stri
|
||||
Config::AddLayer(ConfigLoaders::GenerateGlobalGameConfigLoader(game_id, revision));
|
||||
Config::AddLayer(ConfigLoaders::GenerateLocalGameConfigLoader(game_id, revision));
|
||||
|
||||
if (Core::IsRunning())
|
||||
if (Core::IsRunning(system))
|
||||
DolphinAnalytics::Instance().ReportGameStart();
|
||||
}
|
||||
|
||||
void SConfig::OnNewTitleLoad(const Core::CPUThreadGuard& guard)
|
||||
{
|
||||
if (!Core::IsRunning())
|
||||
auto& system = guard.GetSystem();
|
||||
if (!Core::IsRunning(system))
|
||||
return;
|
||||
|
||||
auto& system = guard.GetSystem();
|
||||
auto& ppc_symbol_db = system.GetPPCSymbolDB();
|
||||
if (!ppc_symbol_db.IsEmpty())
|
||||
{
|
||||
|
||||
@@ -190,7 +190,7 @@ std::string StopMessage(bool main_thread, std::string_view message)
|
||||
|
||||
void DisplayMessage(std::string message, int time_in_ms)
|
||||
{
|
||||
if (!IsRunning())
|
||||
if (!IsRunning(Core::System::GetInstance()))
|
||||
return;
|
||||
|
||||
// Actually displaying non-ASCII could cause things to go pear-shaped
|
||||
@@ -200,9 +200,8 @@ void DisplayMessage(std::string message, int time_in_ms)
|
||||
OSD::AddMessage(std::move(message), time_in_ms);
|
||||
}
|
||||
|
||||
bool IsRunning()
|
||||
bool IsRunning(Core::System& system)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
return (GetState(system) != State::Uninitialized || s_hardware_initialized) && !s_is_stopping;
|
||||
}
|
||||
|
||||
@@ -237,7 +236,7 @@ bool Init(Core::System& system, std::unique_ptr<BootParameters> boot, const Wind
|
||||
{
|
||||
if (s_emu_thread.joinable())
|
||||
{
|
||||
if (IsRunning())
|
||||
if (IsRunning(system))
|
||||
{
|
||||
PanicAlertFmtT("Emu Thread already running");
|
||||
return false;
|
||||
@@ -842,7 +841,7 @@ static bool PauseAndLock(Core::System& system, bool do_lock, bool unpause_on_unl
|
||||
void RunOnCPUThread(Core::System& system, std::function<void()> function, bool wait_for_completion)
|
||||
{
|
||||
// If the CPU thread is not running, assume there is no active CPU thread we can race against.
|
||||
if (!IsRunning() || IsCPUThread())
|
||||
if (!IsRunning(system) || IsCPUThread())
|
||||
{
|
||||
function();
|
||||
return;
|
||||
@@ -1038,7 +1037,7 @@ void HostDispatchJobs(Core::System& system)
|
||||
// Core::State::Uninitialized: s_is_booting -> s_hardware_initialized
|
||||
// We need to check variables in the same order as the state
|
||||
// transition, otherwise we race and get transient failures.
|
||||
if (!job.run_after_stop && !s_is_booting.IsSet() && !IsRunning())
|
||||
if (!job.run_after_stop && !s_is_booting.IsSet() && !IsRunning(system))
|
||||
continue;
|
||||
|
||||
guard.unlock();
|
||||
|
||||
@@ -134,7 +134,7 @@ void UndeclareAsHostThread();
|
||||
|
||||
std::string StopMessage(bool main_thread, std::string_view message);
|
||||
|
||||
bool IsRunning();
|
||||
bool IsRunning(Core::System& system);
|
||||
bool IsRunningAndStarted(); // is running and the CPU loop has been entered
|
||||
bool IsCPUThread(); // this tells us whether we are the CPU thread.
|
||||
bool IsGPUThread();
|
||||
|
||||
@@ -55,10 +55,11 @@ static void WalkTheStack(const Core::CPUThreadGuard& guard,
|
||||
// instead of "pointing ahead"
|
||||
bool GetCallstack(const Core::CPUThreadGuard& guard, std::vector<CallstackEntry>& output)
|
||||
{
|
||||
auto& power_pc = guard.GetSystem().GetPowerPC();
|
||||
auto& system = guard.GetSystem();
|
||||
auto& power_pc = system.GetPowerPC();
|
||||
const auto& ppc_state = power_pc.GetPPCState();
|
||||
|
||||
if (!Core::IsRunning() || !PowerPC::MMU::HostIsRAMAddress(guard, ppc_state.gpr[1]))
|
||||
if (!Core::IsRunning(system) || !PowerPC::MMU::HostIsRAMAddress(guard, ppc_state.gpr[1]))
|
||||
return false;
|
||||
|
||||
if (LR(ppc_state) == 0)
|
||||
|
||||
@@ -212,7 +212,7 @@ void FifoPlayer::Close()
|
||||
|
||||
bool FifoPlayer::IsPlaying() const
|
||||
{
|
||||
return GetFile() != nullptr && Core::IsRunning();
|
||||
return GetFile() != nullptr && Core::IsRunning(m_system);
|
||||
}
|
||||
|
||||
class FifoPlayer::CPUCore final : public CPUCoreBase
|
||||
|
||||
@@ -255,7 +255,7 @@ void ProcessorInterfaceManager::IOSNotifyPowerButtonCallback(Core::System& syste
|
||||
|
||||
void ProcessorInterfaceManager::ResetButton_Tap()
|
||||
{
|
||||
if (!Core::IsRunning())
|
||||
if (!Core::IsRunning(m_system))
|
||||
return;
|
||||
|
||||
auto& core_timing = m_system.GetCoreTiming();
|
||||
@@ -268,7 +268,7 @@ void ProcessorInterfaceManager::ResetButton_Tap()
|
||||
|
||||
void ProcessorInterfaceManager::PowerButton_Tap()
|
||||
{
|
||||
if (!Core::IsRunning())
|
||||
if (!Core::IsRunning(m_system))
|
||||
return;
|
||||
|
||||
auto& core_timing = m_system.GetCoreTiming();
|
||||
|
||||
@@ -533,7 +533,7 @@ bool EmulationKernel::BootIOS(const u64 ios_title_id, HangPPC hang_ppc,
|
||||
|
||||
void EmulationKernel::InitIPC()
|
||||
{
|
||||
if (!Core::IsRunning())
|
||||
if (!Core::IsRunning(m_system))
|
||||
return;
|
||||
|
||||
INFO_LOG_FMT(IOS, "IPC initialised.");
|
||||
|
||||
@@ -425,7 +425,7 @@ bool MovieManager::IsNetPlayRecording() const
|
||||
// NOTE: Host Thread
|
||||
void MovieManager::ChangePads()
|
||||
{
|
||||
if (!Core::IsRunning())
|
||||
if (!Core::IsRunning(m_system))
|
||||
return;
|
||||
|
||||
ControllerTypeArray controllers{};
|
||||
@@ -572,7 +572,7 @@ bool MovieManager::BeginRecordingInput(const ControllerTypeArray& controllers,
|
||||
ConfigLoaders::SaveToDTM(&header);
|
||||
Config::AddLayer(ConfigLoaders::GenerateMovieConfigLoader(&header));
|
||||
|
||||
if (Core::IsRunning())
|
||||
if (Core::IsRunning(m_system))
|
||||
Core::UpdateWantDeterminism(m_system);
|
||||
};
|
||||
Core::RunOnCPUThread(m_system, start_recording, true);
|
||||
|
||||
@@ -856,7 +856,7 @@ static void LoadFileStateData(const std::string& filename, std::vector<u8>& ret_
|
||||
|
||||
void LoadAs(Core::System& system, const std::string& filename)
|
||||
{
|
||||
if (!Core::IsRunning())
|
||||
if (!Core::IsRunning(system))
|
||||
return;
|
||||
|
||||
if (NetPlay::IsNetPlayRunning())
|
||||
|
||||
Reference in new issue
Block a user