]> git.sesse.net Git - vlc/blobdiff - src/modules/entry.c
raop: handle VLC_ADD_LIBS
[vlc] / src / modules / entry.c
index 989d5b9fe175b05bb77677da47d7a5f2631ef18a..60543db4312883ceb5866b2a3ece0ffe43ce35c7 100644 (file)
@@ -83,8 +83,14 @@ module_t *vlc_module_create (module_t *parent)
     return module;
 }
 
+/**
+ * Destroys a plug-in.
+ * @warning If the plug-in is loaded in memory, the handle will be leaked.
+ */
 void vlc_module_destroy (module_t *module)
 {
+    assert (!module->b_loaded || !module->b_unloadable);
+
     for (module_t *m = module->submodule, *next; m != NULL; m = next)
     {
         next = m->next;
@@ -139,8 +145,14 @@ static module_config_t *vlc_config_create (module_t *module, int type)
 }
 
 
-int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
+/**
+ * Callback for the plugin descriptor functions.
+ */
+static int vlc_plugin_setter (void *plugin, void *tgt, int propid, ...)
 {
+    module_t **pprimary = plugin;
+    module_t *module = tgt;
+    module_config_t *item = tgt;
     va_list ap;
     int ret = 0;
 
@@ -149,18 +161,20 @@ int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
     {
         case VLC_MODULE_CREATE:
         {
-            module_t **pp = va_arg (ap, module_t **);
+            module = *pprimary;
             module_t *submodule = vlc_module_create (module);
-
             if (unlikely(submodule == NULL))
             {
                 ret = -1;
                 break;
             }
 
-            *pp = submodule;
-            if (module == NULL)
+            *(va_arg (ap, module_t **)) = submodule;
+            if (*pprimary == NULL)
+            {
+                *pprimary = submodule;
                 break;
+            }
             /* Inheritance. Ugly!! */
             submodule->pp_shortcuts = xmalloc (sizeof (char **));
             submodule->pp_shortcuts[0] = strdup_null (module->pp_shortcuts[0]);
@@ -176,9 +190,14 @@ int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
         {
             int type = va_arg (ap, int);
             module_config_t **pp = va_arg (ap, module_config_t **);
-            *pp = vlc_config_create (module, type);
-            if (*pp == NULL)
+
+            item = vlc_config_create (*pprimary, type);
+            if (unlikely(item == NULL))
+            {
                 ret = -1;
+                break;
+            }
+            *pp = item;
             break;
         }
 
@@ -300,18 +319,16 @@ int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
 
         case VLC_CONFIG_RANGE:
         {
-            if (IsConfigIntegerType (item->i_type)
-             || !CONFIG_ITEM(item->i_type))
-            {
-                item->min.i = va_arg (ap, int64_t);
-                item->max.i = va_arg (ap, int64_t);
-            }
-            else
             if (IsConfigFloatType (item->i_type))
             {
                 item->min.f = va_arg (ap, double);
                 item->max.f = va_arg (ap, double);
             }
+            else
+            {
+                item->min.i = va_arg (ap, int64_t);
+                item->max.i = va_arg (ap, int64_t);
+            }
             break;
         }
 
@@ -342,14 +359,6 @@ int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
             item->i_short = va_arg (ap, int);
             break;
 
-        case VLC_CONFIG_OLDNAME:
-        {
-            const char *oldname = va_arg (ap, const char *);
-            assert (item->psz_oldname == NULL);
-            item->psz_oldname = oldname ? strdup (oldname) : NULL;
-            break;
-        }
-
         case VLC_CONFIG_SAFE:
             item->b_safe = true;
             break;
@@ -459,3 +468,19 @@ int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
     va_end (ap);
     return ret;
 }
+
+/**
+ * Runs a plug-in descriptor. This loads the plug-in meta-data in memory.
+ */
+module_t *vlc_plugin_describe (vlc_plugin_cb entry)
+{
+    module_t *module = NULL;
+
+    if (entry (vlc_plugin_setter, &module) != 0)
+    {
+        if (module != NULL) /* partially initialized plug-in... */
+            vlc_module_destroy (module);
+        module = NULL;
+    }
+    return module;
+}