summaryrefslogtreecommitdiff
path: root/apps/plugins/lastfm_scrobbler.c
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2023-03-20 22:15:33 -0400
committerWilliam Wilgus <me.theuser@yahoo.com>2023-03-25 10:02:43 -0400
commita2e5d9563f9dec84907f4f2060af6dfad895c4ba (patch)
treee2c27f4fca350e1f1ce8ba2ef8fe30fbb341c3c0 /apps/plugins/lastfm_scrobbler.c
parent2e99e2175b48cc00274b03bb4aecf5d01403110d (diff)
downloadrockbox-a2e5d9563f9dec84907f4f2060af6dfad895c4ba.tar.gz
rockbox-a2e5d9563f9dec84907f4f2060af6dfad895c4ba.zip
[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
Diffstat (limited to 'apps/plugins/lastfm_scrobbler.c')
-rw-r--r--apps/plugins/lastfm_scrobbler.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/apps/plugins/lastfm_scrobbler.c b/apps/plugins/lastfm_scrobbler.c
index 5565eed4c5..dce6be0d1e 100644
--- a/apps/plugins/lastfm_scrobbler.c
+++ b/apps/plugins/lastfm_scrobbler.c
@@ -98,7 +98,7 @@ static struct
98 bool force_flush; 98 bool force_flush;
99} gCache; 99} gCache;
100 100
101static struct 101static struct lastfm_config
102{ 102{
103 int savepct; 103 int savepct;
104 int beeplvl; 104 int beeplvl;
@@ -528,7 +528,7 @@ void thread_quit(void)
528} 528}
529 529
530/* callback to end the TSR plugin, called before a new one gets loaded */ 530/* callback to end the TSR plugin, called before a new one gets loaded */
531static bool exit_tsr(bool reenter) 531static int exit_tsr(bool reenter)
532{ 532{
533 MENUITEM_STRINGLIST(menu, ID2P(LANG_AUDIOSCROBBLER), NULL, ID2P(LANG_SETTINGS), 533 MENUITEM_STRINGLIST(menu, ID2P(LANG_AUDIOSCROBBLER), NULL, ID2P(LANG_SETTINGS),
534 "Flush Cache", "Exit Plugin", ID2P(LANG_BACK)); 534 "Flush Cache", "Exit Plugin", ID2P(LANG_BACK));
@@ -556,19 +556,13 @@ static bool exit_tsr(bool reenter)
556 case 2: /* exit plugin - quit */ 556 case 2: /* exit plugin - quit */
557 if(rb->gui_syncyesno_run(&quit_prompt, NULL, NULL) == YESNO_YES) 557 if(rb->gui_syncyesno_run(&quit_prompt, NULL, NULL) == YESNO_YES)
558 { 558 {
559 scrobbler_flush_cache();
559 thread_quit(); 560 thread_quit();
560 if (reenter) 561 return (reenter ? PLUGIN_TSR_TERMINATE : PLUGIN_TSR_SUSPEND);
561 rb->plugin_tsr(NULL); /* remove TSR cb */
562 return !reenter;
563 } 562 }
564 563 /* Fall Through */
565 if(!reenter)
566 return false;
567
568 break;
569
570 case 3: /* back to menu */ 564 case 3: /* back to menu */
571 return false; 565 return PLUGIN_TSR_CONTINUE;
572 } 566 }
573 } 567 }
574} 568}
@@ -576,7 +570,17 @@ static bool exit_tsr(bool reenter)
576/****************** main ******************/ 570/****************** main ******************/
577static int plugin_main(const void* parameter) 571static int plugin_main(const void* parameter)
578{ 572{
579 (void)parameter; 573 struct lastfm_config cfg;
574 rb->memcpy(&cfg, & gConfig, sizeof(struct lastfm_config));
575
576 /* Resume plugin ? */
577 if (parameter == rb->plugin_tsr)
578 {
579
580 gConfig.beeplvl = 0;
581 gConfig.playback = false;
582 gConfig.verbose = false;
583 }
580 584
581 rb->memset(&gThread, 0, sizeof(gThread)); 585 rb->memset(&gThread, 0, sizeof(gThread));
582 if (gConfig.verbose) 586 if (gConfig.verbose)
@@ -586,9 +590,11 @@ static int plugin_main(const void* parameter)
586 rb->plugin_tsr(exit_tsr); /* stay resident */ 590 rb->plugin_tsr(exit_tsr); /* stay resident */
587 591
588 thread_create(); 592 thread_create();
593 rb->memcpy(&gConfig, &cfg, sizeof(struct lastfm_config));
589 594
590 if (gConfig.playback) 595 if (gConfig.playback)
591 return PLUGIN_GOTO_WPS; 596 return PLUGIN_GOTO_WPS;
597
592 return PLUGIN_OK; 598 return PLUGIN_OK;
593} 599}
594 600