summaryrefslogtreecommitdiff
path: root/apps/plugin.c
diff options
context:
space:
mode:
authorJonathan Gordon <rockbox@jdgordon.info>2006-10-31 11:17:00 +0000
committerJonathan Gordon <rockbox@jdgordon.info>2006-10-31 11:17:00 +0000
commit29e259a29190a5ec67dbffc85389a1cb71a9fe26 (patch)
treefbb8615c108ee177f378444952b89009f5527519 /apps/plugin.c
parent23f127ddd7ccda46f88597307cd6df3da3a98c0c (diff)
downloadrockbox-29e259a29190a5ec67dbffc85389a1cb71a9fe26.tar.gz
rockbox-29e259a29190a5ec67dbffc85389a1cb71a9fe26.zip
* give tsr plugins the choice to quit or not
* bumps plugin api version git-svn-id: svn://svn.rockbox.org/rockbox/trunk@11405 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugin.c')
-rw-r--r--apps/plugin.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/apps/plugin.c b/apps/plugin.c
index bc8419d313..518fdeff44 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -88,7 +88,8 @@ extern unsigned char pluginbuf[];
88/* for actual plugins only, not for codecs */ 88/* for actual plugins only, not for codecs */
89static bool plugin_loaded = false; 89static bool plugin_loaded = false;
90static int plugin_size = 0; 90static int plugin_size = 0;
91static void (*pfn_tsr_exit)(void) = NULL; /* TSR exit callback */ 91static bool (*pfn_tsr_exit)(bool) = NULL; /* TSR exit callback */
92static char current_plugin[MAX_PATH];
92 93
93static const struct plugin_api rockbox_api = { 94static const struct plugin_api rockbox_api = {
94 95
@@ -248,6 +249,7 @@ static const struct plugin_api rockbox_api = {
248 ata_sleep, 249 ata_sleep,
249 ata_disk_is_active, 250 ata_disk_is_active,
250#endif 251#endif
252 ata_spindown,
251 reload_directory, 253 reload_directory,
252 254
253 /* dir */ 255 /* dir */
@@ -317,6 +319,7 @@ static const struct plugin_api rockbox_api = {
317 memchr, 319 memchr,
318 memcmp, 320 memcmp,
319 strcasestr, 321 strcasestr,
322 strtok_r,
320 /* unicode stuff */ 323 /* unicode stuff */
321 utf8decode, 324 utf8decode,
322 iso_decode, 325 iso_decode,
@@ -464,21 +467,21 @@ static const struct plugin_api rockbox_api = {
464 show_logo, 467 show_logo,
465 tree_get_context, 468 tree_get_context,
466 469
467 /* new stuff at the end, sort into place next time
468 the API gets incompatible */
469
470 strtok_r,
471#ifdef HAVE_WHEEL_POSITION 470#ifdef HAVE_WHEEL_POSITION
472 wheel_status, 471 wheel_status,
473 wheel_send_events, 472 wheel_send_events,
474#endif 473#endif
475 ata_spindown, 474
475 /* new stuff at the end, sort into place next time
476 the API gets incompatible */
477
476}; 478};
477 479
478int plugin_load(const char* plugin, void* parameter) 480int plugin_load(const char* plugin, void* parameter)
479{ 481{
480 int rc; 482 int rc;
481 struct plugin_header *hdr; 483 struct plugin_header *hdr;
484 const char *p = strrchr(plugin,'/');
482#ifdef SIMULATOR 485#ifdef SIMULATOR
483 void *pd; 486 void *pd;
484#else 487#else
@@ -495,14 +498,23 @@ int plugin_load(const char* plugin, void* parameter)
495 fb_data* old_backdrop; 498 fb_data* old_backdrop;
496#endif 499#endif
497 500
501 if (!p)
502 p = plugin;
503 action_signalscreenchange();
504
498 if (pfn_tsr_exit != NULL) /* if we have a resident old plugin: */ 505 if (pfn_tsr_exit != NULL) /* if we have a resident old plugin: */
499 { 506 {
500 pfn_tsr_exit(); /* force it to exit now */ 507 if (pfn_tsr_exit(!strcmp(current_plugin,p)) == false )
508 {
509 /* not allowing another plugin to load */
510 return PLUGIN_OK;
511 }
501 pfn_tsr_exit = NULL; 512 pfn_tsr_exit = NULL;
502 plugin_loaded = false; 513 plugin_loaded = false;
503 } 514 }
504 515
505 gui_syncsplash(0, true, str(LANG_WAIT)); 516 gui_syncsplash(0, true, str(LANG_WAIT));
517 strcpy(current_plugin,p);
506 518
507#ifdef SIMULATOR 519#ifdef SIMULATOR
508 hdr = sim_plugin_load((char *)plugin, &pd); 520 hdr = sim_plugin_load((char *)plugin, &pd);
@@ -635,7 +647,6 @@ int plugin_load(const char* plugin, void* parameter)
635 gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_ERROR)); 647 gui_syncsplash(HZ*2, true, str(LANG_PLUGIN_ERROR));
636 break; 648 break;
637 } 649 }
638 action_signalscreenchange();
639 return PLUGIN_OK; 650 return PLUGIN_OK;
640} 651}
641 652
@@ -675,7 +686,7 @@ void* plugin_get_audio_buffer(int* buffer_size)
675/* The plugin wants to stay resident after leaving its main function, e.g. 686/* The plugin wants to stay resident after leaving its main function, e.g.
676 runs from timer or own thread. The callback is registered to later 687 runs from timer or own thread. The callback is registered to later
677 instruct it to free its resources before a new plugin gets loaded. */ 688 instruct it to free its resources before a new plugin gets loaded. */
678void plugin_tsr(void (*exit_callback)(void)) 689void plugin_tsr(bool (*exit_callback)(bool))
679{ 690{
680 pfn_tsr_exit = exit_callback; /* remember the callback for later */ 691 pfn_tsr_exit = exit_callback; /* remember the callback for later */
681} 692}