[vlc-commits] commit: Add module_start() and module_stop() ( Rémi Denis-Courmont )

git at videolan.org git at videolan.org
Tue Jul 27 21:36:26 CEST 2010


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Tue Jul 27 21:33:06 2010 +0300| [d4e41e6450ec6321cb6d547fbbb16123fbccd039] | committer: Rémi Denis-Courmont 

Add module_start() and module_stop()

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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d4e41e6450ec6321cb6d547fbbb16123fbccd039
---

 include/vlc_modules.h |    3 +++
 src/modules/modules.c |   26 +++++++++++++++-----------
 2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/include/vlc_modules.h b/include/vlc_modules.h
index 2a1fdd5..fa43b5e 100644
--- a/include/vlc_modules.h
+++ b/include/vlc_modules.h
@@ -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 * ) );
 
diff --git a/src/modules/modules.c b/src/modules/modules.c
index 2bc029f..15feab1 100644
--- a/src/modules/modules.c
+++ b/src/modules/modules.c
@@ -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 );
 }
 



More information about the vlc-commits mailing list