enable boost mode as early as possible during init, and exit boost as late as possible during exit.
This commit is contained in:
@@ -192,6 +192,28 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
static void SetBoostMode(bool enable, bool force = false) {
|
||||
static Mutex mutex{};
|
||||
static int ref_count{};
|
||||
|
||||
mutexLock(&mutex);
|
||||
ON_SCOPE_EXIT(mutexUnlock(&mutex));
|
||||
|
||||
if (enable) {
|
||||
ref_count++;
|
||||
appletSetCpuBoostMode(ApmCpuBoostMode_FastLoad);
|
||||
} else {
|
||||
if (ref_count) {
|
||||
ref_count--;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ref_count || force) {
|
||||
ref_count = 0;
|
||||
appletSetCpuBoostMode(ApmCpuBoostMode_Normal);
|
||||
}
|
||||
}
|
||||
|
||||
static auto GetAccountList() -> std::vector<AccountProfileBase> {
|
||||
std::vector<AccountProfileBase> out;
|
||||
|
||||
|
||||
@@ -1283,8 +1283,8 @@ void App::ScanThemeEntries() {
|
||||
App::App(const char* argv0) {
|
||||
TimeStamp ts;
|
||||
|
||||
appletSetCpuBoostMode(ApmCpuBoostMode_FastLoad);
|
||||
ON_SCOPE_EXIT(appletSetCpuBoostMode(ApmCpuBoostMode_Normal));
|
||||
// boost mode is enabled in userAppInit().
|
||||
ON_SCOPE_EXIT(App::SetBoostMode(false));
|
||||
|
||||
g_app = this;
|
||||
m_start_timestamp = armGetSystemTick();
|
||||
@@ -1851,8 +1851,8 @@ void App::DisplayDumpOptions(bool left_side) {
|
||||
}
|
||||
|
||||
App::~App() {
|
||||
appletSetCpuBoostMode(ApmCpuBoostMode_FastLoad);
|
||||
ON_SCOPE_EXIT(appletSetCpuBoostMode(ApmCpuBoostMode_Normal));
|
||||
// boost mode is disabled in userAppExit().
|
||||
App::SetBoostMode(true);
|
||||
|
||||
log_write("starting to exit\n");
|
||||
TimeStamp ts;
|
||||
|
||||
@@ -16,7 +16,7 @@ int main(int argc, char** argv) {
|
||||
extern "C" {
|
||||
|
||||
void userAppInit(void) {
|
||||
Result rc;
|
||||
sphaira::App::SetBoostMode(true);
|
||||
|
||||
// https://github.com/mtheall/ftpd/blob/e27898f0c3101522311f330e82a324861e0e3f7e/source/switch/init.c#L31
|
||||
const SocketInitConfig socket_config_application = {
|
||||
@@ -47,6 +47,7 @@ void userAppInit(void) {
|
||||
|
||||
const auto socket_config = is_application ? socket_config_application : socket_config_applet;
|
||||
|
||||
Result rc;
|
||||
if (R_FAILED(rc = appletLockExit()))
|
||||
diagAbortWithResult(rc);
|
||||
if (R_FAILED(rc = socketInitialize(&socket_config)))
|
||||
@@ -87,6 +88,8 @@ void userAppExit(void) {
|
||||
if (auto fs = fsdevGetDeviceFileSystem("sdmc:")) {
|
||||
fsFsCommit(fs);
|
||||
}
|
||||
|
||||
sphaira::App::SetBoostMode(false);
|
||||
appletUnlockExit();
|
||||
}
|
||||
|
||||
|
||||
@@ -1170,8 +1170,8 @@ void Menu::SetIndex(s64 index) {
|
||||
}
|
||||
|
||||
void Menu::ScanHomebrew() {
|
||||
appletSetCpuBoostMode(ApmCpuBoostMode_FastLoad);
|
||||
ON_SCOPE_EXIT(appletSetCpuBoostMode(ApmCpuBoostMode_Normal));
|
||||
App::SetBoostMode(true);
|
||||
ON_SCOPE_EXIT(App::SetBoostMode(false));
|
||||
|
||||
from_json(REPO_PATH, m_entries);
|
||||
|
||||
|
||||
@@ -968,8 +968,8 @@ void FsView::UploadFiles() {
|
||||
}
|
||||
|
||||
auto FsView::Scan(const fs::FsPath& new_path, bool is_walk_up) -> Result {
|
||||
appletSetCpuBoostMode(ApmCpuBoostMode_FastLoad);
|
||||
ON_SCOPE_EXIT(appletSetCpuBoostMode(ApmCpuBoostMode_Normal));
|
||||
App::SetBoostMode(true);
|
||||
ON_SCOPE_EXIT(App::SetBoostMode(false));
|
||||
|
||||
log_write("new scan path: %s\n", new_path.s);
|
||||
if (!is_walk_up && !m_path.empty() && !m_entries_current.empty()) {
|
||||
|
||||
@@ -1101,8 +1101,8 @@ void Menu::ScanHomebrew() {
|
||||
const auto hide_forwarders = m_hide_forwarders.Get();
|
||||
TimeStamp ts;
|
||||
|
||||
appletSetCpuBoostMode(ApmCpuBoostMode_FastLoad);
|
||||
ON_SCOPE_EXIT(appletSetCpuBoostMode(ApmCpuBoostMode_Normal));
|
||||
App::SetBoostMode(true);
|
||||
ON_SCOPE_EXIT(App::SetBoostMode(false));
|
||||
|
||||
FreeEntries();
|
||||
m_entries.reserve(ENTRY_CHUNK_COUNT);
|
||||
|
||||
@@ -980,8 +980,8 @@ Result Menu::DumpGames(u32 flags) {
|
||||
R_TRY(GcMountStorage());
|
||||
|
||||
const auto do_dump = [this](u32 flags) -> Result {
|
||||
appletSetCpuBoostMode(ApmCpuBoostMode_FastLoad);
|
||||
ON_SCOPE_EXIT(appletSetCpuBoostMode(ApmCpuBoostMode_Normal));
|
||||
App::SetBoostMode(true);
|
||||
ON_SCOPE_EXIT(App::SetBoostMode(false));
|
||||
|
||||
u32 location_flags = dump::DumpLocationFlag_All;
|
||||
|
||||
|
||||
@@ -581,8 +581,8 @@ void Menu::PackListDownload() {
|
||||
curl::Flags{curl::Flag_Cache},
|
||||
curl::StopToken{this->GetToken()},
|
||||
curl::OnComplete{[this, page_index](auto& result){
|
||||
appletSetCpuBoostMode(ApmCpuBoostMode_FastLoad);
|
||||
ON_SCOPE_EXIT(appletSetCpuBoostMode(ApmCpuBoostMode_Normal));
|
||||
App::SetBoostMode(true);
|
||||
ON_SCOPE_EXIT(App::SetBoostMode(false));
|
||||
|
||||
log_write("got themezer data\n");
|
||||
if (!result.success) {
|
||||
|
||||
@@ -21,7 +21,7 @@ void threadFunc(void* arg) {
|
||||
|
||||
ProgressBox::ProgressBox(int image, const std::string& action, const std::string& title, ProgressBoxCallback callback, ProgressBoxDoneCallback done, int cpuid, int prio, int stack_size) {
|
||||
if (App::GetApp()->m_progress_boost_mode.Get()) {
|
||||
appletSetCpuBoostMode(ApmCpuBoostMode_FastLoad);
|
||||
App::SetBoostMode(true);
|
||||
}
|
||||
|
||||
SetAction(Button::B, Action{"Back"_i18n, [this](){
|
||||
@@ -67,7 +67,7 @@ ProgressBox::~ProgressBox() {
|
||||
FreeImage();
|
||||
m_done(m_thread_data.result);
|
||||
|
||||
appletSetCpuBoostMode(ApmCpuBoostMode_Normal);
|
||||
App::SetBoostMode(false);
|
||||
}
|
||||
|
||||
auto ProgressBox::Update(Controller* controller, TouchInfo* touch) -> void {
|
||||
|
||||
Reference in New Issue
Block a user