static module_t * AllocatePlugin( vlc_object_t *, char * );
#endif
static int AllocateBuiltinModule( vlc_object_t *, int ( * ) ( module_t * ) );
-static int DeleteModule ( module_t * );
+static int DeleteModule ( module_t *, vlc_bool_t );
#ifdef HAVE_DYNAMIC_PLUGINS
static void DupModule ( module_t * );
static void UndupModule ( module_t * );
{
if( p_bank->pp_loaded_cache[p_bank->i_loaded_cache] )
{
- DeleteModule (p_bank->pp_loaded_cache[p_bank->i_loaded_cache]->p_module);
+ DeleteModule( p_bank->pp_loaded_cache[p_bank->i_loaded_cache]->p_module, p_bank->pp_loaded_cache[p_bank->i_loaded_cache]->b_used );
free( p_bank->pp_loaded_cache[p_bank->i_loaded_cache]->psz_file );
free( p_bank->pp_loaded_cache[p_bank->i_loaded_cache] );
p_bank->pp_loaded_cache[p_bank->i_loaded_cache] = NULL;
{
p_next = (module_t *)p_this->p_libvlc_global->p_module_bank->pp_children[0];
- if( DeleteModule( p_next ) )
+ if( DeleteModule( p_next, VLC_TRUE ) )
{
/* Module deletion failed */
msg_Err( p_this, "module \"%s\" can't be removed, trying harder",
{
CacheMerge( p_this, p_module, p_new_module );
vlc_object_attach( p_new_module, p_module );
- DeleteModule( p_new_module );
+ DeleteModule( p_new_module, VLC_TRUE );
}
}
#endif
p_item < p_end; p_item++ )
{
if( p_item->pf_callback || p_item->i_action )
+ {
p_module = AllocatePlugin( p_this, psz_file );
+ break;
+ }
}
+ if( p_module == p_cache_entry->p_module )
+ p_cache_entry->b_used = VLC_TRUE;
}
}
p_bank->pp_cache[p_bank->i_cache]->i_time = i_file_time;
p_bank->pp_cache[p_bank->i_cache]->i_size = i_file_size;
p_bank->pp_cache[p_bank->i_cache]->b_junk = p_module ? 0 : 1;
+ p_bank->pp_cache[p_bank->i_cache]->b_used = VLC_TRUE;
p_bank->pp_cache[p_bank->i_cache]->p_module = p_module;
p_bank->i_cache++;
}
*****************************************************************************
* This function can only be called if the module isn't being used.
*****************************************************************************/
-static int DeleteModule( module_t * p_module )
+static int DeleteModule( module_t * p_module, vlc_bool_t b_detach )
{
if( !p_module ) return VLC_EGENERIC;
- vlc_object_detach( p_module );
+ if( b_detach )
+ vlc_object_detach( p_module );
/* We free the structures that we strdup()ed in Allocate*Module(). */
#ifdef HAVE_DYNAMIC_PLUGINS
LOAD_IMMEDIATE( pp_cache[i]->i_time );
LOAD_IMMEDIATE( pp_cache[i]->i_size );
LOAD_IMMEDIATE( pp_cache[i]->b_junk );
+ pp_cache[i]->b_used = VLC_FALSE;
if( pp_cache[i]->b_junk ) continue;
}
/*****************************************************************************
- * FindPluginCache: finds the cache entry corresponding to a file
+ * CacheFind: finds the cache entry corresponding to a file
*****************************************************************************/
static module_cache_t *CacheFind( vlc_object_t *p_this, char *psz_file,
int64_t i_time, int64_t i_size )