]> git.sesse.net Git - vlc/commitdiff
Add module_start() and module_stop()
authorRémi Denis-Courmont <remi@remlab.net>
Tue, 27 Jul 2010 18:33:06 +0000 (21:33 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Tue, 27 Jul 2010 19:33:37 +0000 (22:33 +0300)
This can be used to restart a plugin without going through the whole
module_need(). This only makes sense if you are sure that the plugin
will accept the object parameters. In other words, do not change any
object parameter that could influence the plugin probing decision.

include/vlc_modules.h
src/modules/modules.c

index 2a1fdd52785c4e4578af0a31e1c2aae789b06425..fa43b5e7d12fcd6bfc152eff9501bcd90500bd3c 100644 (file)
@@ -37,6 +37,9 @@ VLC_EXPORT( void, module_unneed, ( vlc_object_t *, module_t * ) );
 VLC_EXPORT( bool,  module_exists, (const char *) );
 VLC_EXPORT( module_t *, module_find, (const char *) );
 
+int module_start(vlc_object_t *, module_t *);
+void module_stop(vlc_object_t *, module_t *);
+
 VLC_EXPORT( module_config_t *, module_config_get, ( const module_t *, unsigned * ) );
 VLC_EXPORT( void, module_config_free, ( module_config_t * ) );
 
index 2bc029f4f6cbbe7495528696402b0498db0898b4..15feab162a7f0218125c9fea26adff7dee695acf 100644 (file)
@@ -323,6 +323,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()
@@ -555,10 +568,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! */
@@ -620,14 +630,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 );
 }