]> git.sesse.net Git - vlc/blobdiff - src/modules/modules.c
Use var_Inherit* instead of var_CreateGet*.
[vlc] / src / modules / modules.c
index 6020b14683fc893b6248c873a19e2a0e34d43612..c5e2c4f451ac1b3ab62a5478db81c2e9a03ddd71 100644 (file)
@@ -31,6 +31,7 @@
 #include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_memory.h>
+#include <vlc_modules.h>
 #include "libvlc.h"
 
 #include <stdlib.h>                                      /* free(), strtol() */
 #include <string.h>                                              /* strdup() */
 #include <assert.h>
 
-#ifdef HAVE_DIRENT_H
-#   include <dirent.h>
-#endif
-
 #include <sys/types.h>
 #ifdef HAVE_SYS_STAT_H
 #   include <sys/stat.h>
@@ -304,6 +301,8 @@ const char *module_gettext (const module_t *m, const char *str)
 {
 #ifdef ENABLE_NLS
     const char *domain = m->domain ? m->domain : PACKAGE_NAME;
+    if (unlikely(str == NULL || *str == '\0'))
+        return "";
     return dgettext (domain, str);
 #else
     (void)m;
@@ -322,6 +321,19 @@ void module_release (module_t *m)
     vlc_release (&m->vlc_gc_data);
 }
 
+#undef module_start
+int module_start (vlc_object_t *obj, module_t *m)
+{
+   return m->pf_activate ? (m->pf_activate (obj)) : VLC_SUCCESS;
+}
+
+#undef module_stop
+void module_stop (vlc_object_t *obj, module_t *m)
+{
+    if (m->pf_deactivate)
+        m->pf_deactivate (obj);
+}
+
 /**
  * Frees the flat list of VLC modules.
  * @param list list obtained by module_list_get()
@@ -554,10 +566,7 @@ found_shortcut:
 
         p_this->b_force = p_list[i].b_force;
 
-        int ret = VLC_SUCCESS;
-        if( p_cand->pf_activate )
-            ret = p_cand->pf_activate( p_this );
-        switch( ret )
+        switch( module_start( p_this, p_cand ) )
         {
         case VLC_SUCCESS:
             /* good module! */
@@ -619,14 +628,8 @@ found_shortcut:
  */
 void module_unneed( vlc_object_t * p_this, module_t * p_module )
 {
-    /* Use the close method */
-    if( p_module->pf_deactivate )
-    {
-        p_module->pf_deactivate( p_this );
-    }
-
     msg_Dbg( p_this, "removing module \"%s\"", p_module->psz_object_name );
-
+    module_stop( p_this, p_module );
     module_release( p_module );
 }