Change module_Exists to take the module name (and not short name) as parameter. Update the only known use of that function acordingly.
#define module_Exists(a,b) __module_Exists(VLC_OBJECT(a),b)
VLC_EXPORT( vlc_bool_t, __module_Exists, ( vlc_object_t *, const char * ) );
+/* Use only if you know what you're doing... */
+#define module_FindName(a,b) __module_FindName(VLC_OBJECT(a),b)
+VLC_EXPORT( module_t *, __module_FindName, ( vlc_object_t *, const char * ) );
+
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) );
fmt_out.i_chroma = VLC_FOURCC('Y','U','V','A');
/* Find a suitable decoder module */
- if( module_Exists( p_dec, "SDL Image decoder" ) )
+ if( module_Exists( p_dec, "sdl_image" ) )
{
/* ffmpeg thinks it can handle bmp properly but it can't (at least
* not all of them), so use sdl_image if it is available */
char *psz_parser, *psz_string;
char *psz_filter_type;
- msg_Err( p_intf, "FIXME %s %s %d.", __FILE__, __func__, __LINE__ );
- return;
-#if 0
/* Please leave p_libvlc_global. This is where cached modules are
* stored. We're not trying to find a module instance. */
- vlc_object_t *p_obj = (vlc_object_t *)
- vlc_object_find_name( vlc_global_object(), psz_name, FIND_CHILD );
+ module_t *p_obj = module_FindName( p_intf, psz_name );
if( !p_obj )
{
msg_Err( p_intf, "Unable to find filter module \"%s\n.", psz_name );
return;
}
- if( module_IsCapable( (module_t*)p_obj, "video filter2" ) )
+ if( module_IsCapable( p_obj, "video filter2" ) )
{
psz_filter_type = "video-filter";
}
- else if( module_IsCapable( (module_t*)p_obj, "video filter" ) )
+ else if( module_IsCapable( p_obj, "video filter" ) )
{
psz_filter_type = "vout-filter";
}
- else if( module_IsCapable( (module_t*)p_obj, "sub filter" ) )
+ else if( module_IsCapable( p_obj, "sub filter" ) )
{
psz_filter_type = "sub-filter";
}
}
free( psz_string );
-#endif
}
void ExtVideo::updateFilters()
}
/*****************************************************************************
- * module_Exists: tell if a module exists.
- *****************************************************************************
- * This function is a boolean function that tells if a module exist or not.
+ * module_FindName: get a pointer to a module_t given it's name.
*****************************************************************************/
-
-vlc_bool_t __module_Exists( vlc_object_t *p_this, const char * psz_name )
+module_t *__module_FindName( vlc_object_t *p_this, const char * psz_name )
{
vlc_list_t *p_list;
int i;
p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
for( i = 0 ; i < p_list->i_count; i++)
{
- const char *psz_module_name =
- ((module_t *) p_list->p_values[i].p_object)->psz_shortname;
+ module_t *p_module = ((module_t *) p_list->p_values[i].p_object);
+ const char *psz_module_name = p_module->psz_object_name;
if( psz_module_name && !strcmp( psz_module_name, psz_name ) )
{
/* We can release the list, and return yes */
- vlc_list_release( p_list ); return VLC_TRUE;
+ vlc_list_release( p_list );
+ vlc_object_yield( p_module );
+ return p_module;
}
}
- vlc_list_release( p_list ); return VLC_FALSE;
+ vlc_list_release( p_list );
+ return NULL;
+}
+
+/*****************************************************************************
+ * module_Exists: tell if a module exists.
+ *****************************************************************************
+ * This function is a boolean function that tells if a module exist or not.
+ *****************************************************************************/
+vlc_bool_t __module_Exists( vlc_object_t *p_this, const char * psz_name )
+{
+ module_t *p_module = __module_FindName( p_this, psz_name );
+ if( p_module )
+ {
+ vlc_object_release( p_module );
+ return VLC_TRUE;
+ }
+ else
+ {
+ return VLC_FALSE;
+ }
}