Commit d283a27b authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Clean up registration of statically linked modules

parent 21e31e34
...@@ -82,7 +82,7 @@ static int AllocatePluginFile( vlc_object_t *, module_bank_t *, const char *, ...@@ -82,7 +82,7 @@ static int AllocatePluginFile( vlc_object_t *, module_bank_t *, const char *,
const struct stat *, cache_mode_t ); const struct stat *, cache_mode_t );
static module_t * AllocatePlugin( vlc_object_t *, const char *, bool ); static module_t * AllocatePlugin( vlc_object_t *, const char *, bool );
#endif #endif
static int AllocateBuiltinModule( vlc_object_t *, int ( * ) ( module_t * ) ); static module_t *module_InitStatic (vlc_plugin_cb);
static void DeleteModule (module_t **, module_t *); static void DeleteModule (module_t **, module_t *);
#undef module_InitBank #undef module_InitBank
...@@ -105,7 +105,7 @@ void module_InitBank( vlc_object_t *p_this ) ...@@ -105,7 +105,7 @@ void module_InitBank( vlc_object_t *p_this )
* library just as another module, and for instance the configuration * library just as another module, and for instance the configuration
* options of main will be available in the module bank structure just * options of main will be available in the module bank structure just
* as for every other module. */ * as for every other module. */
AllocateBuiltinModule( p_this, vlc_entry__main ); module_InitStatic (vlc_entry__main);
vlc_rwlock_init (&config_lock); vlc_rwlock_init (&config_lock);
config_SortConfig (); config_SortConfig ();
} }
...@@ -1023,42 +1023,29 @@ error: ...@@ -1023,42 +1023,29 @@ error:
} }
#endif /* HAVE_DYNAMIC_PLUGINS */ #endif /* HAVE_DYNAMIC_PLUGINS */
/***************************************************************************** /**
* AllocateBuiltinModule: initialize a builtin module. * Registers a statically-linked plug-in.
***************************************************************************** */
* This function registers a builtin module and allocates a structure static module_t *module_InitStatic (vlc_plugin_cb entry)
* for its information data. The module can then be handled by module_need
* and module_unneed. It can be removed by DeleteModule.
*****************************************************************************/
static int AllocateBuiltinModule( vlc_object_t * p_this,
int ( *pf_entry ) ( module_t * ) )
{ {
module_t * p_module; module_t *module = vlc_module_create ();
if (unlikely(module == NULL))
return NULL;
/* Now that we have successfully loaded the module, we can /* Initializes the module */
* allocate a structure for it */ if (entry (module))
p_module = vlc_module_create(); assert (0);
if( p_module == NULL )
return -1;
/* Initialize the module : fill *p_module structure */ module->b_builtin = true;
if( pf_entry( p_module ) != 0 ) module->b_loaded = true;
{ module->b_unloadable = false;
/* With a well-written module we shouldn't have to print an
* additional error message here, but just make sure. */
msg_Err( p_this, "failed calling entry point in builtin module" );
vlc_module_destroy (p_module);
return -1;
}
/* Everything worked fine ! The module is ready to be added to the list. */
p_module->b_builtin = true;
/* LOCK */ /* LOCK */
p_module->next = modules.head; module->next = modules.head;
modules.head = p_module; modules.head = module;
/* UNLOCK */ /* UNLOCK */
return 0; return module;
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -57,6 +57,8 @@ typedef void * module_handle_t; ...@@ -57,6 +57,8 @@ typedef void * module_handle_t;
typedef void * module_handle_t; typedef void * module_handle_t;
#endif #endif
typedef int (*vlc_plugin_cb) (module_t *);
/** /**
* Internal module descriptor * Internal module descriptor
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment