mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-05-25 12:32:39 +00:00
VideoConfig: Remove ConfigChangedCallback on shutdown
This commit is contained in:
parent
d0dc8ae5e1
commit
45b9def42c
3 changed files with 23 additions and 7 deletions
|
@ -50,6 +50,9 @@
|
||||||
#include "UICommon/DiscordPresence.h"
|
#include "UICommon/DiscordPresence.h"
|
||||||
#include "UICommon/USBUtils.h"
|
#include "UICommon/USBUtils.h"
|
||||||
|
|
||||||
|
#include "VideoCommon/VideoBackendBase.h"
|
||||||
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
#ifdef HAVE_QTDBUS
|
#ifdef HAVE_QTDBUS
|
||||||
#include "UICommon/DBusUtils.h"
|
#include "UICommon/DBusUtils.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -58,8 +61,6 @@
|
||||||
#include <IOKit/pwr_mgt/IOPMLib.h>
|
#include <IOKit/pwr_mgt/IOPMLib.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "VideoCommon/VideoBackendBase.h"
|
|
||||||
|
|
||||||
namespace UICommon
|
namespace UICommon
|
||||||
{
|
{
|
||||||
static Config::ConfigChangedCallbackID s_config_changed_callback_id;
|
static Config::ConfigChangedCallbackID s_config_changed_callback_id;
|
||||||
|
@ -152,6 +153,7 @@ void Shutdown()
|
||||||
WiimoteReal::Shutdown();
|
WiimoteReal::Shutdown();
|
||||||
Common::Log::LogManager::Shutdown();
|
Common::Log::LogManager::Shutdown();
|
||||||
Discord::Shutdown();
|
Discord::Shutdown();
|
||||||
|
g_Config.Shutdown();
|
||||||
SConfig::Shutdown();
|
SConfig::Shutdown();
|
||||||
Config::Shutdown();
|
Config::Shutdown();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "VideoCommon/VideoConfig.h"
|
#include "VideoCommon/VideoConfig.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
#include "Common/CPUDetect.h"
|
#include "Common/CPUDetect.h"
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
|
@ -33,7 +34,8 @@
|
||||||
VideoConfig g_Config;
|
VideoConfig g_Config;
|
||||||
VideoConfig g_ActiveConfig;
|
VideoConfig g_ActiveConfig;
|
||||||
BackendInfo g_backend_info;
|
BackendInfo g_backend_info;
|
||||||
static bool s_has_registered_callback = false;
|
static std::optional<CPUThreadConfigCallback::ConfigChangedCallbackID>
|
||||||
|
s_config_changed_callback_id = std::nullopt;
|
||||||
|
|
||||||
static bool IsVSyncActive(bool enabled)
|
static bool IsVSyncActive(bool enabled)
|
||||||
{
|
{
|
||||||
|
@ -50,14 +52,14 @@ void UpdateActiveConfig()
|
||||||
|
|
||||||
void VideoConfig::Refresh()
|
void VideoConfig::Refresh()
|
||||||
{
|
{
|
||||||
if (!s_has_registered_callback)
|
if (!s_config_changed_callback_id.has_value())
|
||||||
{
|
{
|
||||||
// There was a race condition between the video thread and the host thread here, if
|
// There was a race condition between the video thread and the host thread here, if
|
||||||
// corrections need to be made by VerifyValidity(). Briefly, the config will contain
|
// corrections need to be made by VerifyValidity(). Briefly, the config will contain
|
||||||
// invalid values. Instead, pause the video thread first, update the config and correct
|
// invalid values. Instead, pause the video thread first, update the config and correct
|
||||||
// it, then resume emulation, after which the video thread will detect the config has
|
// it, then resume emulation, after which the video thread will detect the config has
|
||||||
// changed and act accordingly.
|
// changed and act accordingly.
|
||||||
CPUThreadConfigCallback::AddConfigChangedCallback([]() {
|
const auto config_changed_callback = []() {
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = Core::System::GetInstance();
|
||||||
|
|
||||||
const bool lock_gpu_thread = Core::IsRunning(system);
|
const bool lock_gpu_thread = Core::IsRunning(system);
|
||||||
|
@ -69,8 +71,10 @@ void VideoConfig::Refresh()
|
||||||
|
|
||||||
if (lock_gpu_thread)
|
if (lock_gpu_thread)
|
||||||
system.GetFifo().PauseAndLock(false, true);
|
system.GetFifo().PauseAndLock(false, true);
|
||||||
});
|
};
|
||||||
s_has_registered_callback = true;
|
|
||||||
|
s_config_changed_callback_id =
|
||||||
|
CPUThreadConfigCallback::AddConfigChangedCallback(config_changed_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
bVSync = Config::Get(Config::GFX_VSYNC);
|
bVSync = Config::Get(Config::GFX_VSYNC);
|
||||||
|
@ -212,6 +216,15 @@ void VideoConfig::VerifyValidity()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VideoConfig::Shutdown()
|
||||||
|
{
|
||||||
|
if (!s_config_changed_callback_id.has_value())
|
||||||
|
return;
|
||||||
|
|
||||||
|
CPUThreadConfigCallback::RemoveConfigChangedCallback(*s_config_changed_callback_id);
|
||||||
|
s_config_changed_callback_id.reset();
|
||||||
|
}
|
||||||
|
|
||||||
bool VideoConfig::UsingUberShaders() const
|
bool VideoConfig::UsingUberShaders() const
|
||||||
{
|
{
|
||||||
return iShaderCompilationMode == ShaderCompilationMode::SynchronousUberShaders ||
|
return iShaderCompilationMode == ShaderCompilationMode::SynchronousUberShaders ||
|
||||||
|
|
|
@ -190,6 +190,7 @@ struct VideoConfig final
|
||||||
VideoConfig() = default;
|
VideoConfig() = default;
|
||||||
void Refresh();
|
void Refresh();
|
||||||
void VerifyValidity();
|
void VerifyValidity();
|
||||||
|
static void Shutdown();
|
||||||
|
|
||||||
// General
|
// General
|
||||||
bool bVSync = false;
|
bool bVSync = false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue