PSP2: Fix file descriptors dying on suspend (fixes #1123)
Vicki Pfau vi@endrift.com
Sun, 24 Feb 2019 12:31:27 -0800
5 files changed,
31 insertions(+),
2 deletions(-)
M
CHANGES
→
CHANGES
@@ -28,6 +28,7 @@ - Qt: Fix quick load recent accidentally saving (fixes mgba.io/i/1309)
- GBA: Fix video timing when skipping BIOS (fixes mgba.io/i/1318) - 3DS: Work around menu freezing (fixes mgba.io/i/1294) - GBA DMA: Fix invalid DMA handling (fixes mgba.io/i/1301) + - PSP2: Fix file descriptors dying on suspend (fixes mgba.io/i/1123) Misc: - GBA Savedata: EEPROM performance fixes - GBA Savedata: Automatically map 1Mbit Flash files as 1Mbit Flash
M
src/feature/gui/gui-runner.c
→
src/feature/gui/gui-runner.c
@@ -271,7 +271,17 @@ size_t len = snprintf(log2, sizeof(log2) - 1, "%s: %s\n", mLogCategoryName(category), log);
if (len >= sizeof(log2)) { len = sizeof(log2) - 1; } - guiLogger->vf->write(guiLogger->vf, log2, len); + if (guiLogger->vf->write(guiLogger->vf, log2, len) < 0) { + char path[PATH_MAX]; + mCoreConfigDirectory(path, PATH_MAX); + strncat(path, PATH_SEP "log", PATH_MAX - strlen(path)); + guiLogger->vf->close(guiLogger->vf); + guiLogger->vf = VFileOpen(path, O_CREAT | O_WRONLY | O_APPEND); + if (guiLogger->vf->write(guiLogger->vf, log2, len) < 0) { + guiLogger->vf->close(guiLogger->vf); + guiLogger->vf = NULL; + } + } } void mGUIRun(struct mGUIRunner* runner, const char* path) {
M
src/platform/psp2/main.c
→
src/platform/psp2/main.c
@@ -160,7 +160,8 @@ .paused = mPSP2Paused,
.unpaused = mPSP2Unpaused, .incrementScreenMode = mPSP2IncrementScreenMode, .setFrameLimiter = mPSP2SetFrameLimiter, - .pollGameInput = mPSP2PollInput + .pollGameInput = mPSP2PollInput, + .running = mPSP2SystemPoll }; sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, SCE_TOUCH_SAMPLING_STATE_START);
M
src/platform/psp2/psp2-context.c
→
src/platform/psp2/psp2-context.c
@@ -25,6 +25,7 @@ #include <mgba-util/threading.h>
#include <mgba-util/vfs.h> #include <mgba-util/platform/psp2/sce-vfs.h> +#include <psp2/appmgr.h> #include <psp2/audioout.h> #include <psp2/camera.h> #include <psp2/ctrl.h>@@ -37,6 +38,9 @@ #include <vita2d.h>
#define RUMBLE_PWM 8 #define CDRAM_ALIGN 0x40000 + +mLOG_DECLARE_CATEGORY(GUI_PSP2); +mLOG_DEFINE_CATEGORY(GUI_PSP2, "Vita", "gui.psp2"); static enum ScreenMode { SM_BACKDROP,@@ -537,6 +541,18 @@
void mPSP2IncrementScreenMode(struct mGUIRunner* runner) { screenMode = (screenMode + 1) % SM_MAX; mCoreConfigSetUIntValue(&runner->config, "screenMode", screenMode); +} + +bool mPSP2SystemPoll(struct mGUIRunner* runner) { + SceAppMgrSystemEvent event; + if (sceAppMgrReceiveSystemEvent(&event) < 0) { + return true; + } + if (event.systemEvent == SCE_APPMGR_SYSTEMEVENT_ON_RESUME) { + mLOG(GUI_PSP2, INFO, "Suspend detected, reloading save"); + mCoreAutoloadSave(runner->core); + } + return true; } __attribute__((noreturn, weak)) void __assert_func(const char* file, int line, const char* func, const char* expr) {
M
src/platform/psp2/psp2-context.h
→
src/platform/psp2/psp2-context.h
@@ -25,5 +25,6 @@ void mPSP2DrawScreenshot(struct mGUIRunner* runner, const color_t* pixels, unsigned width, unsigned height, bool faded);
void mPSP2IncrementScreenMode(struct mGUIRunner* runner); void mPSP2SetFrameLimiter(struct mGUIRunner* runner, bool limit); uint16_t mPSP2PollInput(struct mGUIRunner* runner); +bool mPSP2SystemPoll(struct mGUIRunner* runner); #endif