diff options
author | neonloop | 2023-01-15 07:22:56 +0000 |
---|---|---|
committer | neonloop | 2023-01-15 07:22:56 +0000 |
commit | 798c44a8965e5533764edb9ccae05a5929b01512 (patch) | |
tree | eb65ada94d82a55517ff481c311cbdd180e847cf /funkey | |
parent | 80fee512c3c5485d291451adc8b3437b8a85319f (diff) | |
download | picoarch-798c44a8965e5533764edb9ccae05a5929b01512.tar.gz picoarch-798c44a8965e5533764edb9ccae05a5929b01512.tar.bz2 picoarch-798c44a8965e5533764edb9ccae05a5929b01512.zip |
Fixes occasional instant play failures
When resuming instant play, FunKey S saves path of executable after
launching executable in background. If this happens fast enough,
process will still be /bin/busybox, not /opt/picoarch, saving wrong
path, failing next launch. To workaround, should save path again
before suspending.
Diffstat (limited to 'funkey')
-rw-r--r-- | funkey/fk_instant_play.c | 31 | ||||
-rw-r--r-- | funkey/fk_menu.h | 5 |
2 files changed, 25 insertions, 11 deletions
diff --git a/funkey/fk_instant_play.c b/funkey/fk_instant_play.c index a4aebd3..8c8fc33 100644 --- a/funkey/fk_instant_play.c +++ b/funkey/fk_instant_play.c @@ -33,11 +33,11 @@ #include "fk_menu.h" #include "fk_instant_play.h" #include "core.h" +#include "util.h" #ifndef SHELL_CMD_POWERDOWN -#define SHELL_CMD_POWERDOWN "shutdown_funkey" -#define SHELL_CMD_SCHEDULE_POWERDOWN "sched_shutdown" -#define SHELL_CMD_CANCEL_SCHED_POWERDOWN "cancel_sched_powerdown" +#define SHELL_CMD_POWERDOWN "powerdown" +#define SHELL_CMD_POWERDOWN_HANDLE "powerdown handle" #endif static char *prog_name; @@ -53,7 +53,7 @@ static void handle_sigusr1(int signal) FK_EndMenu(); /* Send command to cancel any previously scheduled powerdown */ - fp = popen(SHELL_CMD_CANCEL_SCHED_POWERDOWN, "r"); + fp = popen(SHELL_CMD_POWERDOWN_HANDLE, "r"); if (fp == NULL) { /* Countdown is still ticking, so better do nothing @@ -74,17 +74,32 @@ static void handle_sigusr1(int signal) void FK_Suspend(void) { + FILE *fp; + char pidcmd[100]; + state_slot = AUTOSAVE_SLOT; - if(!state_write()) { - printf("Save failed"); + if(state_write()) { + printf("Save failed\n"); state_slot = 0; } sram_write(); save_config(CONFIG_TYPE_AUTO); - /* Perform Instant Play save and shutdown */ - execlp(SHELL_CMD_INSTANT_PLAY, SHELL_CMD_INSTANT_PLAY, "save", prog_name, core_path, content->path, NULL); + PA_INFO("Suspending with %s %s %s %s %s\n", SHELL_CMD_INSTANT_PLAY, "save", prog_name, core_path, content->path); + + snprintf(pidcmd, array_size(pidcmd), "pid record %d", getpid()); + + fp = popen(pidcmd, "r"); + if (fp == NULL) + PA_ERROR("Failed to update stored pid\n"); + + pclose(fp); + + fflush(stdout); + + /* Perform Instant Play save and shutdown */ + execlp(SHELL_CMD_INSTANT_PLAY, SHELL_CMD_INSTANT_PLAY, "save", prog_name, core_path, content->path, NULL); /* Should not be reached */ printf("Failed to perform shutdown\n"); diff --git a/funkey/fk_menu.h b/funkey/fk_menu.h index 36bc460..8b9e7a4 100644 --- a/funkey/fk_menu.h +++ b/funkey/fk_menu.h @@ -129,9 +129,8 @@ typedef enum {RESUME_OPTIONS} ENUM_RESUME_OPTIONS; #define SHELL_CMD_USB_CHECK_IS_SHARING "share is_sharing" #endif #ifdef HAS_MENU_POWERDOWN -#define SHELL_CMD_POWERDOWN "shutdown_funkey" -#define SHELL_CMD_SCHEDULE_POWERDOWN "sched_shutdown" -#define SHELL_CMD_CANCEL_SCHED_POWERDOWN "cancel_sched_powerdown" +#define SHELL_CMD_POWERDOWN "powerdown" +#define SHELL_CMD_POWERDOWN_HANDLE "powerdown handle" #endif #ifdef HAS_MENU_LAUNCHER #define SHELL_CMD_SET_LAUNCHER_GMENU2X "set_launcher gmenu2x" |