- if( p_module->i_usage != -1 )
- {
- /* This shouldn't happen. Ever. We have serious problems here. */
- msg_Err( p_module, "plugin module \"%s\" has refcount %i",
- p_module->psz_object_name, p_module->i_usage );
- return -1;
- }
-
- /* i_usage == -1, which means that the module isn't in memory */
- if( module_load( p_module->psz_filename, &p_module->handle ) )
- {
- char psz_buffer[256];
-
- /* The plugin module couldn't be opened */
- msg_Err( p_module, "cannot open `%s' (%s)",
- p_module->psz_filename, module_error(psz_buffer) );
- return -1;
- }
-
- /* FIXME: what to do if the guy modified the plugin while it was
- * unloaded ? It makes XMMS crash nastily, perhaps we should try
- * to be a bit more clever here. */
-
- /* Everything worked fine ! The module is ready to be used */
- p_module->i_usage = 1;
-#endif /* HAVE_DYNAMIC_PLUGINS */
-
- return 0;
-}
-
-/*****************************************************************************
- * UnlockModule: decrease the usage count of a module.
- *****************************************************************************
- * We decrease the usage count of a module so that we know when a module
- * becomes unused and can be hidden.
- *****************************************************************************/
-static int UnlockModule( module_t * p_module )
-{
- if( p_module->i_usage <= 0 )
- {
- /* This shouldn't happen. Ever. We have serious problems here. */
- msg_Err( p_module, "trying to call module_Unneed() on \"%s\" "
- "which is not in use", p_module->psz_object_name );
- return -1;
- }
-
- /* This module is still in use, we can return */
- p_module->i_usage--;
- p_module->i_unused_delay = 0;
-
- return 0;
-}
-
-#ifdef HAVE_DYNAMIC_PLUGINS
-/*****************************************************************************
- * HideModule: remove a module from memory but keep its structure.
- *****************************************************************************
- * This function can only be called if i_usage == 0. It will make a call
- * to the module's inner module_deactivate() symbol, and then unload it
- * from memory. A call to module_Need() will automagically load it again.
- *****************************************************************************/
-static int HideModule( module_t * p_module )
-{
- if( p_module->b_builtin )
- {
- /* A builtin module should never be hidden. */
- msg_Err( p_module, "trying to hide builtin module \"%s\"",
- p_module->psz_object_name );
- return -1;
- }
-
- if( p_module->i_usage >= 1 )
- {
- msg_Err( p_module, "trying to hide module \"%s\" which is still "
- "in use", p_module->psz_object_name );
- return -1;
- }
-
- if( p_module->i_usage <= -1 )
- {
- msg_Err( p_module, "trying to hide module \"%s\" which is already "
- "hidden", p_module->psz_object_name );
- return -1;
- }
-
- /* Everything worked fine, we can safely unload the module. */
- module_unload( p_module->handle );
- p_module->i_usage = -1;
-
- return 0;
-}
-