mirror of
https://github.com/azahar-emu/azahar.git
synced 2026-06-06 02:33:44 -04:00
citra_meta: Move DetachedTasks construction to main.cpp
This commit is contained in:
parent
64516e6420
commit
6634b8c9d9
8 changed files with 51 additions and 51 deletions
|
|
@ -4,6 +4,9 @@
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "common/detached_tasks.h"
|
||||||
|
#include "common/scope_exit.h"
|
||||||
|
|
||||||
#ifdef ENABLE_QT
|
#ifdef ENABLE_QT
|
||||||
#include "citra_qt/citra_qt.h"
|
#include "citra_qt/citra_qt.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -69,6 +72,9 @@ static bool CheckAndReportSSE42() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
|
Common::DetachedTasks detached_tasks;
|
||||||
|
SCOPE_EXIT({ detached_tasks.WaitForAllTasks(); });
|
||||||
|
|
||||||
#if CITRA_HAS_SSE42
|
#if CITRA_HAS_SSE42
|
||||||
if (!CheckAndReportSSE42()) {
|
if (!CheckAndReportSSE42()) {
|
||||||
return 1;
|
return 1;
|
||||||
|
|
@ -84,8 +90,7 @@ int main(int argc, char* argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (launch_room) {
|
if (launch_room) {
|
||||||
LaunchRoom(argc, argv, true);
|
return LaunchRoom(argc, argv, true);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -98,13 +103,12 @@ int main(int argc, char* argv[]) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!no_gui) {
|
if (!no_gui) {
|
||||||
LaunchQtFrontend(argc, argv);
|
return LaunchQtFrontend(argc, argv);
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLE_SDL2_FRONTEND
|
#if ENABLE_SDL2_FRONTEND
|
||||||
LaunchSdlFrontend(argc, argv);
|
return LaunchSdlFrontend(argc, argv);
|
||||||
#else
|
#else
|
||||||
std::cout << "Cannot use SDL frontend as it was disabled at compile time. Exiting."
|
std::cout << "Cannot use SDL frontend as it was disabled at compile time. Exiting."
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,6 @@
|
||||||
#include "citra_qt/util/util.h"
|
#include "citra_qt/util/util.h"
|
||||||
#include "common/arch.h"
|
#include "common/arch.h"
|
||||||
#include "common/common_paths.h"
|
#include "common/common_paths.h"
|
||||||
#include "common/detached_tasks.h"
|
|
||||||
#include "common/dynamic_library/dynamic_library.h"
|
#include "common/dynamic_library/dynamic_library.h"
|
||||||
#include "common/file_util.h"
|
#include "common/file_util.h"
|
||||||
#include "common/literals.h"
|
#include "common/literals.h"
|
||||||
|
|
@ -4240,14 +4239,12 @@ static Qt::HighDpiScaleFactorRoundingPolicy GetHighDpiRoundingPolicy() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void LaunchQtFrontend(int argc, char* argv[]) {
|
int LaunchQtFrontend(int argc, char* argv[]) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
// Ensure that the linker doesn't optimize qt_swizzle.mm out of existence.
|
// Ensure that the linker doesn't optimize qt_swizzle.mm out of existence.
|
||||||
QtSwizzle::Dummy();
|
QtSwizzle::Dummy();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Common::DetachedTasks detached_tasks;
|
|
||||||
|
|
||||||
#if MICROPROFILE_ENABLED
|
#if MICROPROFILE_ENABLED
|
||||||
MicroProfileOnThreadCreate("Frontend");
|
MicroProfileOnThreadCreate("Frontend");
|
||||||
SCOPE_EXIT({ MicroProfileShutdown(); });
|
SCOPE_EXIT({ MicroProfileShutdown(); });
|
||||||
|
|
@ -4317,6 +4314,5 @@ void LaunchQtFrontend(int argc, char* argv[]) {
|
||||||
&GMainWindow::OnAppFocusStateChanged);
|
&GMainWindow::OnAppFocusStateChanged);
|
||||||
|
|
||||||
int result = app.exec();
|
int result = app.exec();
|
||||||
detached_tasks.WaitForAllTasks();
|
return result;
|
||||||
exit(result);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -90,7 +90,7 @@ namespace Service::FS {
|
||||||
enum class MediaType : u32;
|
enum class MediaType : u32;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LaunchQtFrontend(int argc, char* argv[]);
|
int LaunchQtFrontend(int argc, char* argv[]);
|
||||||
|
|
||||||
class GMainWindow : public QMainWindow {
|
class GMainWindow : public QMainWindow {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
#include "common/common_paths.h"
|
#include "common/common_paths.h"
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/detached_tasks.h"
|
|
||||||
#include "common/file_util.h"
|
#include "common/file_util.h"
|
||||||
#include "common/logging/backend.h"
|
#include "common/logging/backend.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
|
@ -160,8 +159,7 @@ static void InitializeLogging(const std::string& log_file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Application entry point
|
/// Application entry point
|
||||||
void LaunchRoom(int argc, char** argv, bool called_by_option) {
|
int LaunchRoom(int argc, char** argv, bool called_by_option) {
|
||||||
Common::DetachedTasks detached_tasks;
|
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
char* endarg;
|
char* endarg;
|
||||||
|
|
||||||
|
|
@ -251,20 +249,20 @@ void LaunchRoom(int argc, char** argv, bool called_by_option) {
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
PrintHelp(argv[0]);
|
PrintHelp(argv[0]);
|
||||||
exit(0);
|
return 0;
|
||||||
case 'v':
|
case 'v':
|
||||||
PrintVersion();
|
PrintVersion();
|
||||||
exit(0);
|
return 0;
|
||||||
case 'e':
|
case 'e':
|
||||||
PrintRemovedOptionWarning(argv[0], "--enable-citra-mods/-e");
|
PrintRemovedOptionWarning(argv[0], "--enable-citra-mods/-e");
|
||||||
exit(255);
|
return 255;
|
||||||
case 'g':
|
case 'g':
|
||||||
PrintRemovedOptionWarning(argv[0], "--preferred-game/-g");
|
PrintRemovedOptionWarning(argv[0], "--preferred-game/-g");
|
||||||
exit(255);
|
return 255;
|
||||||
case 0:
|
case 0:
|
||||||
if (strcmp(long_options[option_index].name, "preferred-game-id") == 0) {
|
if (strcmp(long_options[option_index].name, "preferred-game-id") == 0) {
|
||||||
PrintRemovedOptionWarning(argv[0], "--preferred-game-id");
|
PrintRemovedOptionWarning(argv[0], "--preferred-game-id");
|
||||||
exit(255);
|
return 255;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -273,12 +271,12 @@ void LaunchRoom(int argc, char** argv, bool called_by_option) {
|
||||||
if (room_name.empty()) {
|
if (room_name.empty()) {
|
||||||
std::cout << "room name is empty!\n\n";
|
std::cout << "room name is empty!\n\n";
|
||||||
PrintHelp(argv[0]);
|
PrintHelp(argv[0]);
|
||||||
exit(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
if (preferred_game.empty()) {
|
if (preferred_game.empty()) {
|
||||||
std::cout << "preferred application is empty!\n\n";
|
std::cout << "preferred application is empty!\n\n";
|
||||||
PrintHelp(argv[0]);
|
PrintHelp(argv[0]);
|
||||||
exit(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
if (preferred_game_id == 0) {
|
if (preferred_game_id == 0) {
|
||||||
std::cout
|
std::cout
|
||||||
|
|
@ -289,12 +287,12 @@ void LaunchRoom(int argc, char** argv, bool called_by_option) {
|
||||||
std::cout << "max_members needs to be in the range 2 - "
|
std::cout << "max_members needs to be in the range 2 - "
|
||||||
<< Network::MaxConcurrentConnections << "!\n\n";
|
<< Network::MaxConcurrentConnections << "!\n\n";
|
||||||
PrintHelp(argv[0]);
|
PrintHelp(argv[0]);
|
||||||
exit(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
if (port > 65535) {
|
if (port > 65535) {
|
||||||
std::cout << "port needs to be in the range 0 - 65535!\n\n";
|
std::cout << "port needs to be in the range 0 - 65535!\n\n";
|
||||||
PrintHelp(argv[0]);
|
PrintHelp(argv[0]);
|
||||||
exit(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
if (ban_list_file.empty()) {
|
if (ban_list_file.empty()) {
|
||||||
std::cout << "Ban list file not set!\nThis should get set to load and save room ban "
|
std::cout << "Ban list file not set!\nThis should get set to load and save room ban "
|
||||||
|
|
@ -351,7 +349,7 @@ void LaunchRoom(int argc, char** argv, bool called_by_option) {
|
||||||
if (!room->Create(room_name, room_description, "", port, password, max_members, username,
|
if (!room->Create(room_name, room_description, "", port, password, max_members, username,
|
||||||
preferred_game, preferred_game_id, std::move(verify_backend), ban_list)) {
|
preferred_game, preferred_game_id, std::move(verify_backend), ban_list)) {
|
||||||
std::cout << "Failed to create room: \n\n";
|
std::cout << "Failed to create room: \n\n";
|
||||||
exit(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
std::cout << "Room is open. Close with Q+Enter...\n\n";
|
std::cout << "Room is open. Close with Q+Enter...\n\n";
|
||||||
auto announce_session = std::make_unique<Network::AnnounceMultiplayerSession>();
|
auto announce_session = std::make_unique<Network::AnnounceMultiplayerSession>();
|
||||||
|
|
@ -377,5 +375,5 @@ void LaunchRoom(int argc, char** argv, bool called_by_option) {
|
||||||
room->Destroy();
|
room->Destroy();
|
||||||
}
|
}
|
||||||
Network::Shutdown();
|
Network::Shutdown();
|
||||||
detached_tasks.WaitForAllTasks();
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,4 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
void LaunchRoom(int argc, char** argv, bool called_by_option);
|
int LaunchRoom(int argc, char** argv, bool called_by_option);
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,12 @@
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "citra_room/citra_room.h"
|
#include "citra_room/citra_room.h"
|
||||||
|
#include "common/detached_tasks.h"
|
||||||
|
#include "common/scope_exit.h"
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
|
Common::DetachedTasks detached_tasks;
|
||||||
|
SCOPE_EXIT({ detached_tasks.WaitForAllTasks(); });
|
||||||
|
|
||||||
LaunchRoom(argc, argv, false);
|
LaunchRoom(argc, argv, false);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@
|
||||||
#include "SDL_messagebox.h"
|
#include "SDL_messagebox.h"
|
||||||
#include "citra_meta/common_strings.h"
|
#include "citra_meta/common_strings.h"
|
||||||
#include "common/common_paths.h"
|
#include "common/common_paths.h"
|
||||||
#include "common/detached_tasks.h"
|
|
||||||
#include "common/file_util.h"
|
#include "common/file_util.h"
|
||||||
#include "common/logging/backend.h"
|
#include "common/logging/backend.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
|
|
@ -171,11 +170,10 @@ static void OnStatusMessageReceived(const Network::StatusMessageEntry& msg) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Application entry point
|
/// Application entry point
|
||||||
void LaunchSdlFrontend(int argc, char** argv) {
|
int LaunchSdlFrontend(int argc, char** argv) {
|
||||||
Common::Log::Initialize();
|
Common::Log::Initialize();
|
||||||
Common::Log::SetColorConsoleBackendEnabled(true);
|
Common::Log::SetColorConsoleBackendEnabled(true);
|
||||||
Common::Log::Start();
|
Common::Log::Start();
|
||||||
Common::DetachedTasks detached_tasks;
|
|
||||||
SdlConfig config;
|
SdlConfig config;
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
bool use_gdbstub = Settings::values.use_gdbstub.GetValue();
|
bool use_gdbstub = Settings::values.use_gdbstub.GetValue();
|
||||||
|
|
@ -192,7 +190,7 @@ void LaunchSdlFrontend(int argc, char** argv) {
|
||||||
|
|
||||||
if (argv_w == nullptr) {
|
if (argv_w == nullptr) {
|
||||||
LOG_CRITICAL(Frontend, "Failed to get command line arguments");
|
LOG_CRITICAL(Frontend, "Failed to get command line arguments");
|
||||||
exit(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
std::string filepath;
|
std::string filepath;
|
||||||
|
|
@ -238,12 +236,12 @@ void LaunchSdlFrontend(int argc, char** argv) {
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
if (errno != 0) {
|
if (errno != 0) {
|
||||||
perror("--gdbport");
|
perror("--gdbport");
|
||||||
exit(1);
|
return 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'h':
|
case 'h':
|
||||||
PrintHelp(argv[0]);
|
PrintHelp(argv[0]);
|
||||||
exit(0);
|
return 0;
|
||||||
case 'i': {
|
case 'i': {
|
||||||
const auto cia_progress = [](std::size_t written, std::size_t total) {
|
const auto cia_progress = [](std::size_t written, std::size_t total) {
|
||||||
LOG_INFO(Frontend, "{:02d}%", (written * 100 / total));
|
LOG_INFO(Frontend, "{:02d}%", (written * 100 / total));
|
||||||
|
|
@ -252,7 +250,7 @@ void LaunchSdlFrontend(int argc, char** argv) {
|
||||||
Service::AM::InstallStatus::Success)
|
Service::AM::InstallStatus::Success)
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
if (errno != 0)
|
if (errno != 0)
|
||||||
exit(1);
|
return 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 'p':
|
case 'p':
|
||||||
|
|
@ -273,7 +271,7 @@ void LaunchSdlFrontend(int argc, char** argv) {
|
||||||
if (!std::regex_match(str_arg, re)) {
|
if (!std::regex_match(str_arg, re)) {
|
||||||
std::cout << "Wrong format for option --multiplayer\n";
|
std::cout << "Wrong format for option --multiplayer\n";
|
||||||
PrintHelp(argv[0]);
|
PrintHelp(argv[0]);
|
||||||
exit(0);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::smatch match;
|
std::smatch match;
|
||||||
|
|
@ -288,11 +286,11 @@ void LaunchSdlFrontend(int argc, char** argv) {
|
||||||
if (!std::regex_match(nickname, nickname_re)) {
|
if (!std::regex_match(nickname, nickname_re)) {
|
||||||
std::cout
|
std::cout
|
||||||
<< "Nickname is not valid. Must be 4 to 20 alphanumeric characters.\n";
|
<< "Nickname is not valid. Must be 4 to 20 alphanumeric characters.\n";
|
||||||
exit(0);
|
return 0;
|
||||||
}
|
}
|
||||||
if (address.empty()) {
|
if (address.empty()) {
|
||||||
std::cout << "Address to room must not be empty.\n";
|
std::cout << "Address to room must not be empty.\n";
|
||||||
exit(0);
|
return 0;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -300,7 +298,7 @@ void LaunchSdlFrontend(int argc, char** argv) {
|
||||||
const std::string version_string =
|
const std::string version_string =
|
||||||
std::string("Azahar ") + Common::g_build_fullname;
|
std::string("Azahar ") + Common::g_build_fullname;
|
||||||
ShowCommandOutput("Version", version_string);
|
ShowCommandOutput("Version", version_string);
|
||||||
exit(0);
|
return 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
@ -321,12 +319,12 @@ void LaunchSdlFrontend(int argc, char** argv) {
|
||||||
|
|
||||||
if (filepath.empty()) {
|
if (filepath.empty()) {
|
||||||
LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified");
|
LOG_CRITICAL(Frontend, "Failed to load ROM: No ROM specified");
|
||||||
exit(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!movie_record.empty() && !movie_play.empty()) {
|
if (!movie_record.empty() && !movie_play.empty()) {
|
||||||
LOG_CRITICAL(Frontend, "Cannot both play and record a movie");
|
LOG_CRITICAL(Frontend, "Cannot both play and record a movie");
|
||||||
exit(-1);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& system = Core::System::GetInstance();
|
auto& system = Core::System::GetInstance();
|
||||||
|
|
@ -401,10 +399,10 @@ void LaunchSdlFrontend(int argc, char** argv) {
|
||||||
switch (load_result) {
|
switch (load_result) {
|
||||||
case Core::System::ResultStatus::ErrorGetLoader:
|
case Core::System::ResultStatus::ErrorGetLoader:
|
||||||
LOG_CRITICAL(Frontend, "Failed to obtain loader for {}!", filepath);
|
LOG_CRITICAL(Frontend, "Failed to obtain loader for {}!", filepath);
|
||||||
exit(-1);
|
return -1;
|
||||||
case Core::System::ResultStatus::ErrorLoader:
|
case Core::System::ResultStatus::ErrorLoader:
|
||||||
LOG_CRITICAL(Frontend, "Failed to load ROM!");
|
LOG_CRITICAL(Frontend, "Failed to load ROM!");
|
||||||
exit(-1);
|
return -1;
|
||||||
case Core::System::ResultStatus::ErrorLoader_ErrorEncrypted:
|
case Core::System::ResultStatus::ErrorLoader_ErrorEncrypted:
|
||||||
LOG_CRITICAL(Frontend,
|
LOG_CRITICAL(Frontend,
|
||||||
"The application that you are trying to load must be decrypted before "
|
"The application that you are trying to load must be decrypted before "
|
||||||
|
|
@ -412,16 +410,16 @@ void LaunchSdlFrontend(int argc, char** argv) {
|
||||||
"decrypting applications, please refer to: "
|
"decrypting applications, please refer to: "
|
||||||
"https://web.archive.org/web/20240304210021/https://citra-emu.org/"
|
"https://web.archive.org/web/20240304210021/https://citra-emu.org/"
|
||||||
"wiki/dumping-game-cartridges/");
|
"wiki/dumping-game-cartridges/");
|
||||||
exit(-1);
|
return -1;
|
||||||
case Core::System::ResultStatus::ErrorLoader_ErrorInvalidFormat:
|
case Core::System::ResultStatus::ErrorLoader_ErrorInvalidFormat:
|
||||||
LOG_CRITICAL(Frontend, "Error while loading ROM: The ROM format is not supported.");
|
LOG_CRITICAL(Frontend, "Error while loading ROM: The ROM format is not supported.");
|
||||||
exit(-1);
|
return -1;
|
||||||
case Core::System::ResultStatus::ErrorNotInitialized:
|
case Core::System::ResultStatus::ErrorNotInitialized:
|
||||||
LOG_CRITICAL(Frontend, "CPUCore not initialized");
|
LOG_CRITICAL(Frontend, "CPUCore not initialized");
|
||||||
exit(-1);
|
return -1;
|
||||||
case Core::System::ResultStatus::ErrorSystemMode:
|
case Core::System::ResultStatus::ErrorSystemMode:
|
||||||
LOG_CRITICAL(Frontend, "Failed to determine system mode!");
|
LOG_CRITICAL(Frontend, "Failed to determine system mode!");
|
||||||
exit(-1);
|
return -1;
|
||||||
case Core::System::ResultStatus::Success:
|
case Core::System::ResultStatus::Success:
|
||||||
break; // Expected case
|
break; // Expected case
|
||||||
default:
|
default:
|
||||||
|
|
@ -441,7 +439,7 @@ void LaunchSdlFrontend(int argc, char** argv) {
|
||||||
Network::NoPreferredMac, password);
|
Network::NoPreferredMac, password);
|
||||||
} else {
|
} else {
|
||||||
LOG_ERROR(Network, "Could not access RoomMember");
|
LOG_ERROR(Network, "Could not access RoomMember");
|
||||||
exit(0);
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -524,6 +522,5 @@ void LaunchSdlFrontend(int argc, char** argv) {
|
||||||
Common::Linux::StopGamemode();
|
Common::Linux::StopGamemode();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
detached_tasks.WaitForAllTasks();
|
return 0;
|
||||||
exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright Citra Emulator Project / Lime3DS Emulator Project
|
// Copyright Citra Emulator Project / Azahar Emulator Project
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
void LaunchSdlFrontend(int argc, char** argv);
|
int LaunchSdlFrontend(int argc, char** argv);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue