System: Move settings to HostInterface

This commit is contained in:
Connor McLaughlin
2019-11-08 01:07:39 +10:00
parent e8ebead23d
commit 8c51abaf37
10 changed files with 229 additions and 199 deletions

View File

@ -2,19 +2,20 @@
#include "YBaseLib/ByteStream.h"
#include "YBaseLib/Log.h"
#include "common/audio_stream.h"
#include "host_display.h"
#include "system.h"
Log_SetChannel(HostInterface);
HostInterface::HostInterface()
{
m_settings.Load("settings.ini");
m_settings.SetDefaults();
}
HostInterface::~HostInterface() = default;
bool HostInterface::InitializeSystem(const char* filename, const char* exp1_filename)
{
m_system = std::make_unique<System>(this, m_settings);
m_system = std::make_unique<System>(this);
if (!m_system->Initialize())
{
m_system.reset();
@ -54,6 +55,13 @@ bool HostInterface::InitializeSystem(const char* filename, const char* exp1_file
return true;
}
void HostInterface::ShutdownSystem()
{
m_system.reset();
m_paused = false;
UpdateAudioVisualSync();
}
bool HostInterface::LoadState(const char* filename)
{
ByteStream* stream;
@ -99,3 +107,15 @@ bool HostInterface::SaveState(const char* filename)
stream->Release();
return result;
}
void HostInterface::UpdateAudioVisualSync()
{
const bool speed_limiter_enabled = m_settings.speed_limiter_enabled && !m_speed_limiter_temp_disabled;
const bool audio_sync_enabled = speed_limiter_enabled;
const bool vsync_enabled = !m_system || (speed_limiter_enabled && m_settings.gpu_vsync);
Log_InfoPrintf("Syncing to %s%s", audio_sync_enabled ? "audio" : "",
(speed_limiter_enabled && vsync_enabled) ? " and video" : "");
m_audio_stream->SetSync(false);
m_display->SetVSync(vsync_enabled);
}