From 1b8a752ee3fa1d1f19657edbaa5f98d99b8b2c28 Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 1 Mar 2024 20:58:41 +0100 Subject: [PATCH] Use the time of creating the screenshot, not the time of saving the screenshot --- src/screenshot_utils.cpp | 4 ++++ src/thread.cpp | 11 ++++------- src/thread.h | 1 + 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/screenshot_utils.cpp b/src/screenshot_utils.cpp index 8506496..983ee7b 100644 --- a/src/screenshot_utils.cpp +++ b/src/screenshot_utils.cpp @@ -252,6 +252,9 @@ bool takeScreenshot(GX2ColorBuffer *srcBuffer, GX2ScanTarget scanTarget, GX2Surf goto error; } + OSCalendarTime time; + OSTicksToCalendarTime(OSGetTime(), &time); + param->notificationHandle = screenshot; param->sourceBuffer = (uint8_t *) colorBuffer.surface.image; param->width = width; @@ -262,6 +265,7 @@ bool takeScreenshot(GX2ColorBuffer *srcBuffer, GX2ScanTarget scanTarget, GX2Surf param->quality = quality; param->format = colorBuffer.surface.format; param->scanTarget = scanTarget; + param->time = time; res = sendMessageToThread(param); if (!res) { diff --git a/src/thread.cpp b/src/thread.cpp index b60ec64..c41991a 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -4,7 +4,6 @@ #include "screenshot_utils.h" #include "utils/StringTools.h" #include "utils/logger.h" -#include "utils/utils.h" #include #include #include @@ -14,9 +13,7 @@ FSIOThreadData gThreadData; bool gThreadsRunning; -bool getPath(GX2ScanTarget scanTarget, ImageOutputFormatEnum outputFormat, std::string &path) { - OSCalendarTime output; - OSTicksToCalendarTime(OSGetTime(), &output); +static bool getPath(GX2ScanTarget scanTarget, ImageOutputFormatEnum outputFormat, std::string &path, OSCalendarTime &output) { std::string buffer = string_format("%s%016llX", WIIU_SCREENSHOT_PATH, OSGetTitleID()); if (!gShortNameEn.empty()) { buffer += string_format(" (%s)", gShortNameEn.c_str()); @@ -66,7 +63,7 @@ bool getPath(GX2ScanTarget scanTarget, ImageOutputFormatEnum outputFormat, std:: return true; } -static int32_t fsIOthreadCallback([[maybe_unused]] int argc, const char **argv) { +static int32_t fsIOThreadCallback([[maybe_unused]] int argc, const char **argv) { auto *magic = ((FSIOThreadData *) argv); constexpr int32_t messageSize = sizeof(magic->messages) / sizeof(magic->messages[0]); @@ -81,7 +78,7 @@ static int32_t fsIOthreadCallback([[maybe_unused]] int argc, const char **argv) std::string path; bool success = false; - if (getPath(message->scanTarget, message->outputFormat, path)) { + if (getPath(message->scanTarget, message->outputFormat, path, message->time)) { DEBUG_FUNCTION_LINE("Saving to %s", path.c_str()); auto res = saveTextureAsPicture(path, message->sourceBuffer, message->width, message->height, message->pitch, message->format, message->outputFormat, message->convertRGBtoSRGB, message->quality); if (res) { @@ -155,7 +152,7 @@ void startFSIOThreads() { OSMemoryBarrier(); - if (!OSCreateThread(threadData->thread, &fsIOthreadCallback, 1, (char *) threadData, reinterpret_cast((uint32_t) threadData->stack + stackSize), stackSize, 31, OS_THREAD_ATTRIB_AFFINITY_ANY)) { + if (!OSCreateThread(threadData->thread, &fsIOThreadCallback, 1, (char *) threadData, reinterpret_cast((uint32_t) threadData->stack + stackSize), stackSize, 31, OS_THREAD_ATTRIB_AFFINITY_ANY)) { free(threadData->thread); free(threadData->stack); threadData->setup = false; diff --git a/src/thread.h b/src/thread.h index 1379e67..81e8997 100644 --- a/src/thread.h +++ b/src/thread.h @@ -27,6 +27,7 @@ struct SaveScreenshotMessage { bool convertRGBtoSRGB; int quality; GX2ScanTarget scanTarget; + OSCalendarTime time; }; extern FSIOThreadData gThreadData;