mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-02-19 06:47:43 -07:00
The functions SaveToSYSCONF and LoadFromSYSCONF contain checks for whether emulation is running. The intent of this is that when we're emulating a Wii, the emulated system may write to SYSCONF whenever it likes and does not expect anything else to write to SYSCONF, so the host code shouldn't access SYSCONF while emulation is ongoing. However, Core::IsRunning is an imperfect proxy for whether we've handed over control of SYSCONF to the emulated system yet, as the actual handover happens at a slightly different point in time than when the emulation state is changed. This usually isn't a problem, but in theory it could be a determinism problem if a setting is changed right as emulation is starting, or it could cause the emulated software to briefly misbehave if a setting is changed right as emulation is stopping. Things got worse in72cf2bdb87when I replaced the Core::IsRunning calls with !Core::IsUninitialized. With IsRunning, there was be a period of time where SYSCONF should have been protected but wasn't. With !IsUninitialized, there was a period of time where SYSCONF shouldn't have been protected but was, and crucially, this period of time included the moments where we do setup and teardown of the emulated NAND, which broke transferring SYSCONF settings between the host and the guest.72cf2bdb87was reverted because of this. This commit adds a flag that we explicitly flip when control is handed over to or from the emulated system. This protects the SYSCONF file for exactly as long as is needed.
36 lines
766 B
C++
36 lines
766 B
C++
// Copyright 2016 Dolphin Emulator Project
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#pragma once
|
|
|
|
#include <functional>
|
|
#include <memory>
|
|
|
|
namespace Config
|
|
{
|
|
class ConfigLayerLoader;
|
|
enum class LayerType;
|
|
struct Location;
|
|
} // namespace Config
|
|
|
|
namespace ConfigLoaders
|
|
{
|
|
enum class WriteBackChangedValues
|
|
{
|
|
No,
|
|
Yes,
|
|
};
|
|
|
|
enum class SkipIfControlledByGuest
|
|
{
|
|
No,
|
|
Yes,
|
|
};
|
|
|
|
void TransferSYSCONFControlToGuest();
|
|
void TransferSYSCONFControlFromGuest(WriteBackChangedValues write_back_changed_values);
|
|
void SaveToSYSCONF(Config::LayerType layer, SkipIfControlledByGuest skip,
|
|
std::function<bool(const Config::Location&)> predicate = {});
|
|
std::unique_ptr<Config::ConfigLayerLoader> GenerateBaseConfigLoader();
|
|
} // namespace ConfigLoaders
|