From d4e41e6450ec6321cb6d547fbbb16123fbccd039 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Denis-Courmont?= Date: Tue, 27 Jul 2010 21:33:06 +0300 Subject: [PATCH] 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. --- 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 2a1fdd5278..fa43b5e7d1 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 2bc029f4f6..15feab162a 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 ); } -- 2.39.2