Changeset 712

Show
Ignore:
Timestamp:
04/11/10 12:02:58 (2 years ago)
Author:
conrad
Message:

Track dlopen'd module pointers, dlclose on purge()

This adds remix_unload() functions to loaded modules, calls
plugin->destroy, and keeps a module pointer returned by dlopen() in
remix_plugin.c and remix_ladspa.c.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • libremix/trunk/TODO

    r709 r712  
    1414 
    1515ladspa: 
    16         * implement plugin->destroy 
    17         * keep module pointer returned by dlopen() in remix-ladspa.c, and 
    18           call dlclose() on that from remix_purge(). 
    1916        * free schemes created for each ladspa port 
  • libremix/trunk/src/libremix/remix_context.c

    r553 r712  
    4848  world->purging = 1; 
    4949 
    50   cd_list_apply (env, world->plugins, (CDFunc)remix_plugin_destroy); 
    51   world->plugins = cd_list_free (env, world->plugins); 
    52  
    53   /* XXX: remix_destroy_list (env, world->plugins); */ 
    54   /* XXX:  remix_destroy_list (env, world->bases); */ 
     50  world->plugins = cd_list_destroy_with (env, world->plugins, remix_plugin_destroy); 
     51  remix_plugin_defaults_unload (env); 
     52 
     53  /* TODO: remix_destroy_list (env, world->plugins); */ 
     54  /* TODO:  remix_destroy_list (env, world->bases); */ 
    5555  remix_channelset_defaults_destroy (env); 
    5656  remix_free (ctx); 
  • libremix/trunk/src/libremix/remix_plugin.c

    r553 r712  
    4242#include "remix.h" 
    4343 
     44static CDList * modules_list = CD_EMPTY_LIST; 
     45 
    4446static CDList * 
    4547remix_plugin_initialise_static (RemixEnv * env) 
     
    6062{ 
    6163  void * module; 
     64  CDList * l; 
    6265  RemixPluginInitFunc init; 
    6366 
     
    7073    return CD_EMPTY_LIST; 
    7174  } 
     75 
     76  /* Check that this module has not already been loaded (eg. if it is 
     77   * a symlink etc.) */ 
     78  for (l = modules_list; l; l = l->next) { 
     79    if (l->data.s_pointer == module) { 
     80      dlclose (module); 
     81      return CD_EMPTY_LIST; 
     82    } 
     83  } 
     84 
     85  modules_list = cd_list_append (env, modules_list, CD_POINTER(module)); 
    7286 
    7387  if ((init = dlsym (module, "remix_load")) != NULL) { 
     
    131145} 
    132146 
     147static int 
     148remix_plugin_unload (RemixEnv * env, void * module) 
     149{ 
     150  RemixPluginInitFunc unload; /* TODO: make new unload type */ 
     151 
     152  if ((unload = dlsym (module, "remix_unload")) != NULL) { 
     153    unload (env); 
     154  } 
     155 
     156  dlclose (module); 
     157 
     158  return 0; 
     159} 
     160 
     161void 
     162remix_plugin_defaults_unload (RemixEnv * env) 
     163{ 
     164  CDList * l; 
     165 
     166  modules_list = cd_list_destroy_with (env, modules_list, (CDDestroyFunc)remix_plugin_unload); 
     167} 
     168 
    133169#if 0 
    134170 
  • libremix/trunk/src/libremix/remix_private.h

    r553 r712  
    287287/* remix_plugin */ 
    288288void remix_plugin_defaults_initialise (RemixEnv * env); 
     289void remix_plugin_defaults_unload (RemixEnv * env); 
    289290 
    290291/* remix_deck */ 
  • libremix/trunk/src/plugins/ladspa/remix_ladspa.c

    r708 r712  
    874874  RemixMetaText * mt; 
    875875  RemixParameterScheme * scheme; 
    876   CDList * plugins = CD_EMPTY_LIST; 
     876  CDList * l, * plugins = CD_EMPTY_LIST; 
    877877#define BUF_LEN 256 
    878878  static char buf[BUF_LEN]; 
     
    886886  module = dlopen (path, RTLD_NOW); 
    887887  if (!module) return CD_EMPTY_LIST; 
     888 
     889  /* Check that this module has not already been loaded (eg. if it is 
     890   * a symlink etc.) */ 
     891  for (l = modules_list; l; l = l->next) { 
     892    if (l->data.s_pointer == module) { 
     893      dlclose (module); 
     894      return CD_EMPTY_LIST; 
     895    } 
     896  } 
     897 
     898  modules_list = cd_list_append (env, modules_list, CD_POINTER(module)); 
    888899 
    889900  if ((desc_func = dlsym (module, "ladspa_descriptor"))) { 
     
    10291040    dlclose(l->data.s_pointer); 
    10301041  } 
    1031 
    1032  
     1042 
     1043  modules_list = NULL; 
     1044
     1045