diff --git a/src/core/host_interface.cpp b/src/core/host_interface.cpp index 1526927e1..355bddf56 100644 --- a/src/core/host_interface.cpp +++ b/src/core/host_interface.cpp @@ -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 parameters) { - if (!parameters.state_stream) + if (!parameters->state_stream) { - if (parameters.filename.empty()) + if (parameters->filename.empty()) Log_InfoPrintf("Boot Filename: "); 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(); + 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(); + boot_params->state_stream = std::move(stream); + if (!BootSystem(std::move(boot_params))) { ReportError("Failed to boot system after recreation."); return; diff --git a/src/core/host_interface.h b/src/core/host_interface.h index debce9633..14bacc247 100644 --- a/src/core/host_interface.h +++ b/src/core/host_interface.h @@ -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 parameters); virtual void PauseSystem(bool paused); virtual void ResetSystem(); virtual void DestroySystem(); diff --git a/src/duckstation-nogui/main.cpp b/src/duckstation-nogui/main.cpp index f8cfa78a9..4f3fc15ba 100644 --- a/src/duckstation-nogui/main.cpp +++ b/src/duckstation-nogui/main.cpp @@ -68,8 +68,7 @@ static int Run(std::unique_ptr host_interface, std::unique_p } if (boot_params) - host_interface->BootSystem(*boot_params); - boot_params.reset(); // Need to free resume file handle so auto save on exit works + host_interface->BootSystem(std::move(boot_params)); int result; if (System::IsValid() || !host_interface->InBatchMode()) diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index b0c639e82..7d3bdc5d3 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -478,12 +478,12 @@ void MainWindow::onStartDiscActionTriggered() if (filename.isEmpty()) return; - m_host_interface->bootSystem(std::make_shared(filename.toStdString())); + m_host_interface->bootSystem(std::make_shared(filename.toStdString())); } void MainWindow::onStartBIOSActionTriggered() { - m_host_interface->bootSystem(std::make_shared()); + m_host_interface->bootSystem(std::make_shared()); } void MainWindow::onChangeDiscFromFileActionTriggered() @@ -655,9 +655,8 @@ void MainWindow::onGameListContextMenuRequested(const QPoint& point, const GameL m_host_interface->populateGameListContextMenu(entry, this, &menu); menu.addSeparator(); - connect(menu.addAction(tr("Default Boot")), &QAction::triggered, [this, entry]() { - m_host_interface->bootSystem(std::make_shared(entry->path)); - }); + connect(menu.addAction(tr("Default Boot")), &QAction::triggered, + [this, entry]() { m_host_interface->bootSystem(std::make_shared(entry->path)); }); connect(menu.addAction(tr("Fast Boot")), &QAction::triggered, [this, entry]() { auto boot_params = std::make_shared(entry->path); @@ -976,7 +975,7 @@ void MainWindow::startGameOrChangeDiscs(const std::string& path) if (m_host_interface->CanResumeSystemFromFile(path.c_str())) m_host_interface->resumeSystemFromState(QString::fromStdString(path), true); else - m_host_interface->bootSystem(std::make_shared(path)); + m_host_interface->bootSystem(std::make_shared(path)); } else { diff --git a/src/duckstation-qt/qthostinterface.cpp b/src/duckstation-qt/qthostinterface.cpp index 9e7d6b7c0..60b8d44f9 100644 --- a/src/duckstation-qt/qthostinterface.cpp +++ b/src/duckstation-qt/qthostinterface.cpp @@ -52,7 +52,7 @@ Log_SetChannel(QtHostInterface); QtHostInterface::QtHostInterface(QObject* parent) : QObject(parent), CommonHostInterface() { - qRegisterMetaType>(); + qRegisterMetaType>(); qRegisterMetaType(); qRegisterMetaType(); } @@ -333,17 +333,17 @@ void QtHostInterface::setMainWindow(MainWindow* window) m_main_window = window; } -void QtHostInterface::bootSystem(std::shared_ptr params) +void QtHostInterface::bootSystem(std::shared_ptr params) { if (!isOnWorkerThread()) { QMetaObject::invokeMethod(this, "bootSystem", Qt::QueuedConnection, - Q_ARG(std::shared_ptr, std::move(params))); + Q_ARG(std::shared_ptr, std::move(params))); return; } emit emulationStarting(); - if (!BootSystem(*params)) + if (!BootSystem(std::move(params))) return; // force a frame to be drawn to repaint the window diff --git a/src/duckstation-qt/qthostinterface.h b/src/duckstation-qt/qthostinterface.h index 34e3fd0a0..a5d8a089a 100644 --- a/src/duckstation-qt/qthostinterface.h +++ b/src/duckstation-qt/qthostinterface.h @@ -32,7 +32,7 @@ class INISettingsInterface; class MainWindow; class QtDisplayWidget; -Q_DECLARE_METATYPE(std::shared_ptr); +Q_DECLARE_METATYPE(std::shared_ptr); Q_DECLARE_METATYPE(const GameListEntry*); Q_DECLARE_METATYPE(GPURenderer); @@ -149,7 +149,7 @@ public Q_SLOTS: void applySettings(bool display_osd_messages = false); void updateInputMap(); void applyInputProfile(const QString& profile_path); - void bootSystem(std::shared_ptr params); + void bootSystem(std::shared_ptr params); void resumeSystemFromState(const QString& filename, bool boot_on_failure); void resumeSystemFromMostRecentState(); void powerOffSystem(); diff --git a/src/frontend-common/common_host_interface.cpp b/src/frontend-common/common_host_interface.cpp index 744b2d4fb..abee5352a 100644 --- a/src/frontend-common/common_host_interface.cpp +++ b/src/frontend-common/common_host_interface.cpp @@ -168,13 +168,13 @@ void CommonHostInterface::InitializeUserDirectory() ReportError("Failed to create one or more user directories. This may cause issues at runtime."); } -bool CommonHostInterface::BootSystem(const SystemBootParameters& parameters) +bool CommonHostInterface::BootSystem(std::shared_ptr parameters) { // If the fullscreen UI is enabled, make sure it's finished loading the game list so we don't race it. if (m_display && m_fullscreen_ui_enabled) FullscreenUI::EnsureGameListLoaded(); - ApplyRendererFromGameSettings(parameters.filename); + ApplyRendererFromGameSettings(parameters->filename); if (!HostInterface::BootSystem(parameters)) { @@ -186,8 +186,8 @@ bool CommonHostInterface::BootSystem(const SystemBootParameters& parameters) } // enter fullscreen if requested in the parameters - if (!g_settings.start_paused && ((parameters.override_fullscreen.has_value() && *parameters.override_fullscreen) || - (!parameters.override_fullscreen.has_value() && g_settings.start_fullscreen))) + if (!g_settings.start_paused && ((parameters->override_fullscreen.has_value() && *parameters->override_fullscreen) || + (!parameters->override_fullscreen.has_value() && g_settings.start_fullscreen))) { SetFullscreen(true); } @@ -739,9 +739,7 @@ bool CommonHostInterface::CanResumeSystemFromFile(const char* filename) bool CommonHostInterface::ResumeSystemFromState(const char* filename, bool boot_on_failure) { - SystemBootParameters boot_params; - boot_params.filename = filename; - if (!BootSystem(boot_params)) + if (!BootSystem(std::make_shared(filename))) return false; const bool global = System::GetRunningCode().empty(); diff --git a/src/frontend-common/common_host_interface.h b/src/frontend-common/common_host_interface.h index 0c7e2690b..fea38c842 100644 --- a/src/frontend-common/common_host_interface.h +++ b/src/frontend-common/common_host_interface.h @@ -129,7 +129,7 @@ public: virtual void Shutdown() override; - virtual bool BootSystem(const SystemBootParameters& parameters) override; + virtual bool BootSystem(std::shared_ptr parameters) override; virtual void ResetSystem() override; virtual void DestroySystem() override; diff --git a/src/frontend-common/fullscreen_ui.cpp b/src/frontend-common/fullscreen_ui.cpp index 69b99add6..7ad0abd42 100644 --- a/src/frontend-common/fullscreen_ui.cpp +++ b/src/frontend-common/fullscreen_ui.cpp @@ -551,9 +551,7 @@ static void DoStartPath(const std::string& path, bool allow_resume) return; } - SystemBootParameters params; - params.filename = path; - s_host_interface->BootSystem(params); + s_host_interface->BootSystem(std::make_shared(path)); } static void DoStartFile() @@ -571,10 +569,7 @@ static void DoStartFile() static void DoStartBIOS() { - s_host_interface->RunLater([]() { - SystemBootParameters boot_params; - s_host_interface->BootSystem(boot_params); - }); + s_host_interface->RunLater([]() { s_host_interface->BootSystem(std::make_shared()); }); ClearImGuiFocus(); }