Refactor SystemBootParameters ownership

This commit is contained in:
Silent
2021-06-08 18:38:12 +02:00
parent 4e282cd172
commit e21f2644d0
9 changed files with 32 additions and 41 deletions

View File

@ -83,14 +83,14 @@ s32 HostInterface::GetAudioOutputVolume() const
return g_settings.audio_output_muted ? 0 : g_settings.audio_output_volume;
}
bool HostInterface::BootSystem(const SystemBootParameters& parameters)
bool HostInterface::BootSystem(std::shared_ptr<SystemBootParameters> parameters)
{
if (!parameters.state_stream)
if (!parameters->state_stream)
{
if (parameters.filename.empty())
if (parameters->filename.empty())
Log_InfoPrintf("Boot Filename: <BIOS/Shell>");
else
Log_InfoPrintf("Boot Filename: %s", parameters.filename.c_str());
Log_InfoPrintf("Boot Filename: %s", parameters->filename.c_str());
}
if (!AcquireHostDisplay())
@ -108,7 +108,7 @@ bool HostInterface::BootSystem(const SystemBootParameters& parameters)
// create the audio stream. this will never fail, since we'll just fall back to null
CreateAudioStream();
if (!System::Boot(parameters))
if (!System::Boot(*parameters))
{
if (!System::IsStartupCancelled())
{
@ -417,9 +417,9 @@ bool HostInterface::LoadState(const char* filename)
}
else
{
SystemBootParameters boot_params;
boot_params.state_stream = std::move(stream);
if (!BootSystem(boot_params))
auto boot_params = std::make_shared<SystemBootParameters>();
boot_params->state_stream = std::move(stream);
if (!BootSystem(std::move(boot_params)))
return false;
}
@ -1164,9 +1164,9 @@ void HostInterface::RecreateSystem()
DestroySystem();
SystemBootParameters boot_params;
boot_params.state_stream = std::move(stream);
if (!BootSystem(boot_params))
auto boot_params = std::make_shared<SystemBootParameters>();
boot_params->state_stream = std::move(stream);
if (!BootSystem(std::move(boot_params)))
{
ReportError("Failed to boot system after recreation.");
return;

View File

@ -51,7 +51,7 @@ public:
/// Shuts down the emulator frontend.
virtual void Shutdown();
virtual bool BootSystem(const SystemBootParameters& parameters);
virtual bool BootSystem(std::shared_ptr<SystemBootParameters> parameters);
virtual void PauseSystem(bool paused);
virtual void ResetSystem();
virtual void DestroySystem();