Changeset 5429:f180386475c4 in roaraudio


Ignore:
Timestamp:
03/20/12 12:45:10 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

support to unload plugins from plugin container

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/plugincontainer.h

    r5389 r5429  
    5555 
    5656// plugin loading and unloading: 
    57 int roar_plugincontainer_load(struct roar_plugincontainer * cont, const char * name, struct roar_dl_librarypara * para); 
    58 #if 0 
    59 int roar_plugincontainer_unload(struct roar_plugincontainer * cont, const char * name); 
    60 int roar_plugincontainer_unload_lhandle(struct roar_plugincontainer * cont, struct roar_dl_lhandle * lhandle); 
    61 #endif 
     57int                      roar_plugincontainer_load            (struct roar_plugincontainer * cont, 
     58                                                               const char * name, 
     59                                                               struct roar_dl_librarypara * para); 
     60struct roar_dl_lhandle * roar_plugincontainer_load_lhandle    (struct roar_plugincontainer * cont, 
     61                                                               const char * name, 
     62                                                               struct roar_dl_librarypara * para); 
     63int                      roar_plugincontainer_unload          (struct roar_plugincontainer * cont, 
     64                                                               const char * name); 
     65int                      roar_plugincontainer_unload_lhandle  (struct roar_plugincontainer * cont, 
     66                                                               struct roar_dl_lhandle * lhandle); 
    6267 
    6368// appsched: 
  • libroar/plugincontainer.c

    r5427 r5429  
    141141// plugin loading and unloading: 
    142142int roar_plugincontainer_load(struct roar_plugincontainer * cont, const char * name, struct roar_dl_librarypara * para) { 
     143 struct roar_dl_lhandle * ret = roar_plugincontainer_load_lhandle(cont, name, para); 
     144 
     145 if ( ret == NULL ) 
     146  return -1; 
     147 
     148 roar_dl_unref(ret); 
     149 
     150 return 0; 
     151} 
     152 
     153struct roar_dl_lhandle * roar_plugincontainer_load_lhandle    (struct roar_plugincontainer * cont, 
     154                                                               const char * name, 
     155                                                               struct roar_dl_librarypara * para) { 
    143156 ssize_t idx = -1; 
    144157 size_t i; 
     
    146159 if ( cont == NULL || name == NULL ) { 
    147160  roar_err_set(ROAR_ERROR_FAULT); 
    148   return -1; 
     161  return NULL; 
    149162 } 
    150163 
     
    158171  // return early if we are full. 
    159172  roar_err_set(ROAR_ERROR_NOSPC); 
    160   return -1; 
     173  return NULL; 
    161174 } 
    162175 for (i = 0; i < MAX_PLUGINS; i++) { 
     
    169182 if ( idx == -1 ) { 
    170183  roar_err_set(ROAR_ERROR_NOSPC); 
    171   return -1; 
     184  return NULL; 
    172185 } 
    173186 
    174187 cont->handle[idx] = roar_dl_open(name, ROAR_DL_FLAG_PLUGIN, 1, para); 
    175188 if ( cont->handle[idx] == NULL ) 
    176   return -1; 
     189  return NULL; 
    177190 
    178191 cont->deprefc[idx] = 0; 
    179192 cont->numhandles++; 
    180193 
    181  return 0; 
    182 } 
    183  
    184 #if 0 
     194 roar_dl_ref(cont->handle[idx]); 
     195 return cont->handle[idx]; 
     196} 
     197 
    185198int roar_plugincontainer_unload(struct roar_plugincontainer * cont, const char * name) { 
    186  // get b name, then call roar_plugincontainer_unload_lhandle(). 
    187  roar_err_set(ROAR_ERROR_NOSYS); 
     199 const struct roar_dl_libraryname * libname; 
     200 size_t i; 
     201 
     202 if ( cont == NULL || name == NULL ) { 
     203  roar_err_set(ROAR_ERROR_FAULT); 
     204  return -1; 
     205 } 
     206 
     207 for (i = 0; i < MAX_PLUGINS; i++) { 
     208  if ( cont->handle[i] == NULL ) 
     209   continue; 
     210  libname = roar_dl_getlibname(cont->handle[i]); 
     211  if ( libname == NULL ) 
     212   continue; 
     213 
     214  if ( !strcmp(libname->name, name) ) 
     215   return roar_plugincontainer_unload_lhandle(cont, cont->handle[i]); 
     216 } 
     217 
     218 roar_err_set(ROAR_ERROR_NOENT); 
    188219 return -1; 
    189220} 
     
    219250 return -1; 
    220251} 
    221 #endif 
    222252 
    223253// appsched: 
Note: See TracChangeset for help on using the changeset viewer.