1
0
Fork 0
forked from len0rd/rockbox

[Feature] resume TSR plugins after interruption WIP

save tsr plugin path for later

resume tsr plugin when user stops the interrupting plugin

expand return of tsr_exit function to allow
continue, suspend, terminate

tsr plugins check parameter at start to determine if
the plugin is being resumed

Change-Id: I6fc70de664c7771e7dbc9a1af7a831e7b50b1d15
This commit is contained in:
William Wilgus 2023-03-20 22:15:33 -04:00 committed by William Wilgus
parent 2e99e2175b
commit a2e5d9563f
6 changed files with 176 additions and 123 deletions

View file

@ -98,7 +98,7 @@ static struct
bool force_flush;
} gCache;
static struct
static struct lastfm_config
{
int savepct;
int beeplvl;
@ -528,7 +528,7 @@ void thread_quit(void)
}
/* callback to end the TSR plugin, called before a new one gets loaded */
static bool exit_tsr(bool reenter)
static int exit_tsr(bool reenter)
{
MENUITEM_STRINGLIST(menu, ID2P(LANG_AUDIOSCROBBLER), NULL, ID2P(LANG_SETTINGS),
"Flush Cache", "Exit Plugin", ID2P(LANG_BACK));
@ -556,19 +556,13 @@ static bool exit_tsr(bool reenter)
case 2: /* exit plugin - quit */
if(rb->gui_syncyesno_run(&quit_prompt, NULL, NULL) == YESNO_YES)
{
scrobbler_flush_cache();
thread_quit();
if (reenter)
rb->plugin_tsr(NULL); /* remove TSR cb */
return !reenter;
return (reenter ? PLUGIN_TSR_TERMINATE : PLUGIN_TSR_SUSPEND);
}
if(!reenter)
return false;
break;
/* Fall Through */
case 3: /* back to menu */
return false;
return PLUGIN_TSR_CONTINUE;
}
}
}
@ -576,7 +570,17 @@ static bool exit_tsr(bool reenter)
/****************** main ******************/
static int plugin_main(const void* parameter)
{
(void)parameter;
struct lastfm_config cfg;
rb->memcpy(&cfg, & gConfig, sizeof(struct lastfm_config));
/* Resume plugin ? */
if (parameter == rb->plugin_tsr)
{
gConfig.beeplvl = 0;
gConfig.playback = false;
gConfig.verbose = false;
}
rb->memset(&gThread, 0, sizeof(gThread));
if (gConfig.verbose)
@ -586,9 +590,11 @@ static int plugin_main(const void* parameter)
rb->plugin_tsr(exit_tsr); /* stay resident */
thread_create();
rb->memcpy(&gConfig, &cfg, sizeof(struct lastfm_config));
if (gConfig.playback)
return PLUGIN_GOTO_WPS;
return PLUGIN_OK;
}