From: RĂ©mi Denis-Courmont Date: Sat, 4 Aug 2007 17:28:18 +0000 (+0000) Subject: Partially abstract module_t: add module_IsCapable() X-Git-Tag: 0.9.0-test0~6658 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;ds=sidebyside;h=6c11c08a800fa57846e69fb86a42164f2570dfe4;p=vlc Partially abstract module_t: add module_IsCapable() --- diff --git a/include/vlc_modules.h b/include/vlc_modules.h index 95f432494c..38b8eee9ed 100644 --- a/include/vlc_modules.h +++ b/include/vlc_modules.h @@ -46,6 +46,7 @@ typedef shl_t module_handle_t; /** * Module descriptor */ +/* FIXME: scheduled for privatization */ struct module_t { VLC_COMMON_MEMBERS @@ -65,7 +66,7 @@ struct module_t /** Shortcuts to the module */ const char *pp_shortcuts[ MODULE_SHORTCUT_MAX ]; - const char *psz_capability; /**< Capability */ + char *psz_capability; /**< Capability */ int i_score; /**< Score for the capability */ uint32_t i_cpu; /**< Required CPU capabilities */ @@ -110,7 +111,7 @@ VLC_EXPORT( module_t *, vlc_module_create, ( vlc_object_t * ) ); VLC_EXPORT( module_t *, vlc_submodule_create, ( module_t * ) ); VLC_EXPORT( int, vlc_module_set, (module_t *module, int propid, void *value) ); -enum +enum vlc_module_properties { /* DO NOT EVER REMOVE, INSERT OR REPLACE ANY ITEM! It would break the ABI! * Append new items at the end ONLY. */ @@ -128,3 +129,4 @@ enum VLC_MODULE_NAME }; +VLC_EXPORT( vlc_bool_t, module_IsCapable, ( const module_t *, const char *cap ) ); diff --git a/src/libvlc.sym b/src/libvlc.sym index 339e4c044d..ab54cb7d8d 100644 --- a/src/libvlc.sym +++ b/src/libvlc.sym @@ -177,6 +177,7 @@ mdate __module_Exists __module_Need __module_Unneed +module_IsCapable __msg_Dbg __msg_Err __msg_Generic diff --git a/src/modules/modules.c b/src/modules/modules.c index f5786eaa2e..fdf1236833 100644 --- a/src/modules/modules.c +++ b/src/modules/modules.c @@ -383,6 +383,14 @@ void __module_LoadPlugins( vlc_object_t * p_this ) #endif } +/***************************************************************************** + * module_IsCapable: checks whether a module implements a capability. + *****************************************************************************/ +vlc_bool_t module_IsCapable( const module_t *m, const char *cap ) +{ + return !strcmp( m->psz_capability, cap ); +} + /***************************************************************************** * module_Need: return the best module function, given a capability list. ***************************************************************************** @@ -479,7 +487,7 @@ module_t * __module_Need( vlc_object_t *p_this, const char *psz_capability, p_module = (module_t *)p_all->p_values[i_which_module].p_object; /* Test that this module can do what we need */ - if( strcmp( p_module->psz_capability, psz_capability ) ) + if( !module_IsCapable( p_module, psz_capability ) ) { /* Don't recurse through the sub-modules because vlc_list_find() * will list them anyway. */ @@ -1199,7 +1207,7 @@ static void UndupModule( module_t *p_module ) } free( (void*)p_module->psz_object_name ); - free( (void*)p_module->psz_capability ); + free( p_module->psz_capability ); free( (void*)p_module->psz_shortname ); free( (void*)p_module->psz_longname ); free( (void*)p_module->psz_help );