]> git.sesse.net Git - vlc/commitdiff
Add new module_FindName function to find a module when given it's name. Use this...
authorAntoine Cellerier <dionoea@videolan.org>
Wed, 22 Aug 2007 22:08:54 +0000 (22:08 +0000)
committerAntoine Cellerier <dionoea@videolan.org>
Wed, 22 Aug 2007 22:08:54 +0000 (22:08 +0000)
Change module_Exists to take the module name (and not short name) as parameter. Update the only known use of that function acordingly.

include/vlc_modules.h
modules/codec/subtitles/subsdec.c
modules/gui/qt4/components/extended_panels.cpp
src/modules/modules.c

index 1bb9f61370c1a951597b16b6494f4f33644e22b3..d93289d8b0e4a7133602fb215128880ac604be7c 100644 (file)
@@ -109,6 +109,10 @@ VLC_EXPORT( void, __module_Unneed, ( vlc_object_t *, module_t * ) );
 #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) );
index a0c30150584f27994affad8d41c234c6dcb1b732..2e38cbff2029b0890787f03bddd5001504a3b7da 100644 (file)
@@ -756,7 +756,7 @@ static int ParseImageAttachments( decoder_t *p_dec )
                     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 */
index 23876c472609ace11464fcbc51d2f487e6576989..2ade730a4af0729addf3cb42005082d090b07a1f 100644 (file)
@@ -208,29 +208,25 @@ void ExtVideo::ChangeVFiltersString( char *psz_name, vlc_bool_t b_add )
     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";
     }
@@ -311,7 +307,6 @@ void ExtVideo::ChangeVFiltersString( char *psz_name, vlc_bool_t b_add )
     }
 
     free( psz_string );
-#endif
 }
 
 void ExtVideo::updateFilters()
index 3d2e10386887c98b44b225b3cac15dc5e4e74cb6..c4a235598905af937926f276022fb1b12c202a0d 100644 (file)
@@ -766,27 +766,46 @@ void __module_Unneed( vlc_object_t * p_this, module_t * p_module )
 }
 
 /*****************************************************************************
- * 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;
+    }
 }