]> git.sesse.net Git - vlc/commitdiff
* ./src/misc/modules.c: if a plugin requested not to be unloaded, then we
authorSam Hocevar <sam@videolan.org>
Wed, 21 Aug 2002 17:31:58 +0000 (17:31 +0000)
committerSam Hocevar <sam@videolan.org>
Wed, 21 Aug 2002 17:31:58 +0000 (17:31 +0000)
    won't unload it. This makes us more fault-tolerant with crap libraries
    that are making use of atexit().
  * ./configure.in: svgalib can now be a plugin.
  * ./modules/misc/gtk_main.c: gtk_main doesn't need g_atexit anymore.

configure
configure.in
include/modules.h
include/modules_inner.h
modules/misc/gtk_main.c
modules/video_output/svgalib.c
src/misc/modules.c

index 020edfefbff53b698bebe4fb38e4ed9ce86667c5..ff20205922a5aa0705f76d59a0cf7c58d6f4dc09 100755 (executable)
--- a/configure
+++ b/configure
@@ -8153,7 +8153,7 @@ fi
 
 if test "x${enable_svgalib}" = "xyes"
 then
-  BUILTINS="${BUILTINS} video_output/svgalib"
+  PLUGINS="${PLUGINS} video_output/svgalib"
   svgalib_LDFLAGS="${svgalib_LDFLAGS} -lvgagl -lvga"
 fi
 
index d5f7f56acea03ddb67787d27cb02986c39bb3200..82574c675950f4cc3ba9715cde46a029078bd0b9 100644 (file)
@@ -1435,7 +1435,7 @@ AC_ARG_ENABLE(svgalib,
   [  --enable-svgalib        SVGAlib support (default disabled)])
 if test "x${enable_svgalib}" = "xyes"
 then
-  BUILTINS="${BUILTINS} video_output/svgalib"
+  PLUGINS="${PLUGINS} video_output/svgalib"
   svgalib_LDFLAGS="${svgalib_LDFLAGS} -lvgagl -lvga"
 fi
 
index 45a830ea885027641f1a6176cebdc0722a726f02..7182d9b14d04d6c4ded46d271009251433c76ebb 100644 (file)
@@ -2,7 +2,7 @@
  * modules.h : Module management functions.
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: modules.h,v 1.60 2002/08/15 12:11:15 sam Exp $
+ * $Id: modules.h,v 1.61 2002/08/21 17:31:58 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -71,6 +71,8 @@ struct module_t
     int   i_score;                              /* Score for each capability */
     u32   i_cpu;                                /* Required CPU capabilities */
 
+    vlc_bool_t b_unloadable;                          /* Can we be dlclosed? */
+    vlc_bool_t b_reentrant;                             /* Are we reentrant? */
     vlc_bool_t b_submodule;                          /* Is this a submodule? */
 
     /* Callbacks */
index cd2c5d9026d223629e87882fa6eb4849ff545a1c..431f142e608410c20713d4865bded23f93b922b3 100644 (file)
@@ -2,7 +2,7 @@
  * modules_inner.h : Macros used from within a module.
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: modules_inner.h,v 1.30 2002/08/14 17:06:53 sam Exp $
+ * $Id: modules_inner.h,v 1.31 2002/08/21 17:31:58 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -87,6 +87,8 @@
         module_config_t p_config[ 100 ];                                      \
         STORE_SYMBOLS;                                                        \
         p_module->b_submodule = VLC_FALSE;                                    \
+        p_module->b_unloadable = VLC_TRUE;                                    \
+        p_module->b_reentrant = VLC_TRUE;                                     \
         p_module->psz_object_name = MODULE_STRING;                            \
         p_module->psz_longname = MODULE_STRING;                               \
         p_module->pp_shortcuts[ 0 ] = MODULE_STRING;                          \
     i_shortcut++
 
 #define set_description( desc )                                               \
-    p_module->psz_longname = desc
+    p_submodule->psz_longname = desc
 
 #define set_capability( cap, score )                                          \
     p_submodule->psz_capability = cap;                                        \
     p_submodule->pf_activate = activate;                                      \
     p_submodule->pf_deactivate = deactivate
 
+#define linked_with_a_crap_library_which_uses_atexit( )                       \
+    p_module->b_unloadable = VLC_FALSE
+
 /*
  * module_activate: this function is called before functions can be accessed,
  * we do allocation tasks here, and maybe additional stuff such as large
index a2132641f3b8ce3ac63fcdfd531083c3860af382..ba05ec959579eb8ffeb3ea8405ceba7125acc6f3 100644 (file)
@@ -2,7 +2,7 @@
  * gtk_main.c : Gtk+ wrapper for gtk_main
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: gtk_main.c,v 1.3 2002/08/21 15:55:15 sam Exp $
+ * $Id: gtk_main.c,v 1.4 2002/08/21 17:31:58 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *
@@ -51,15 +51,11 @@ typedef struct gtk_main_t
 {
     VLC_COMMON_MEMBERS
 
-    /* XXX: Ugly kludge, see g_atexit */
-    void ( *pf_callback[MAX_ATEXIT] ) ( void );
-
 } gtk_main_t;
 
 /*****************************************************************************
  * Local variables (mutex-protected).
  *****************************************************************************/
-static void **       pp_global_data = NULL;
 static int           i_refcount = 0;
 static gtk_main_t *  p_gtk_main = NULL;
 
@@ -67,7 +63,6 @@ static gtk_main_t *  p_gtk_main = NULL;
  * Module descriptor
  *****************************************************************************/
 vlc_module_begin();
-    pp_global_data = p_module->p_vlc->pp_global_data;
     set_description( _("Gtk+ helper module") );
     set_capability( "gtk_main", 100 );
     add_shortcut( "gtk" );
@@ -75,59 +70,14 @@ vlc_module_begin();
     add_shortcut( "gnome" );
 #endif
     set_callbacks( Open, Close );
+    linked_with_a_crap_library_which_uses_atexit();
 vlc_module_end();
 
-/*****************************************************************************
- * g_atexit: kludge to avoid the Gtk+ thread to segfault at exit
- *****************************************************************************
- * gtk_init() makes several calls to g_atexit() which calls atexit() to
- * register tidying callbacks to be called at program exit. Since the Gtk+
- * plugin is likely to be unloaded at program exit, we have to export this
- * symbol to intercept the g_atexit() calls. Talk about crude hack.
- *****************************************************************************/
-void g_atexit( GVoidFunc func )
-{
-    gtk_main_t *p_this;
-
-    int i_dummy;
-
-    if( pp_global_data == NULL )
-    {
-        atexit( func );
-        return;
-    }
-
-    p_this = (gtk_main_t *)*pp_global_data;
-    if( p_this == NULL )
-    {
-        /* Looks like this atexit() call wasn't for us. */
-        return;
-    }
-
-    for( i_dummy = 0;
-         i_dummy < MAX_ATEXIT && p_this->pf_callback[i_dummy] != NULL;
-         i_dummy++ )
-    {
-        ;
-    }
-
-    if( i_dummy >= MAX_ATEXIT - 1 )
-    {
-        msg_Err( p_this, "too many atexit() callbacks to register" );
-        return;
-    }
-
-    p_this->pf_callback[i_dummy]     = func;
-    p_this->pf_callback[i_dummy + 1] = NULL;
-}
-
 /*****************************************************************************
  * Open: initialize and create window
  *****************************************************************************/
 static int Open( vlc_object_t *p_this )
 {
-    /* Initialize Gtk+ */
-
     vlc_mutex_lock( p_this->p_vlc->p_global_lock );
 
     if( i_refcount > 0 )
@@ -139,7 +89,6 @@ static int Open( vlc_object_t *p_this )
     }
 
     p_gtk_main = vlc_object_create( p_this, sizeof(gtk_main_t) );
-    p_gtk_main->pf_callback[0] = NULL;
 
     /* Only initialize gthreads if it's the first time we do it */
     if( !g_thread_supported() )
@@ -168,8 +117,6 @@ static int Open( vlc_object_t *p_this )
  *****************************************************************************/
 static void Close( vlc_object_t *p_this )
 {
-    int i_dummy;
-
     vlc_mutex_lock( p_this->p_vlc->p_global_lock );
 
     i_refcount--;
@@ -183,14 +130,6 @@ static void Close( vlc_object_t *p_this )
     gtk_main_quit();
     vlc_thread_join( p_gtk_main );
 
-    /* Launch stored callbacks */
-    for( i_dummy = 0;
-         i_dummy < MAX_ATEXIT && p_gtk_main->pf_callback[i_dummy] != NULL;
-         i_dummy++ )
-    {
-        p_gtk_main->pf_callback[i_dummy]();
-    }
-
     vlc_object_destroy( p_gtk_main );
     p_gtk_main = NULL;
 
@@ -218,10 +157,6 @@ static void GtkMain( vlc_object_t *p_this )
 #endif
     static int    i_args   = 1;
 
-    /* gtk_init will register stuff with g_atexit, so we need to have
-     * the global lock if we want to be able to intercept the calls */
-    *p_this->p_vlc->pp_global_data = p_gtk_main;
-
     /* FIXME: deprecated ? */
     /* gdk_threads_init(); */
 
index 03dbba3617a037e3ef280aa1ed000f617797133d..344bd2c7980b9e9f26b043366d02171a6afe14f4 100644 (file)
@@ -2,7 +2,7 @@
  * svgalib.c : SVGAlib plugin for vlc
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: svgalib.c,v 1.1 2002/08/21 15:10:33 sam Exp $
+ * $Id: svgalib.c,v 1.2 2002/08/21 17:31:58 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *      
@@ -53,6 +53,7 @@ vlc_module_begin();
     set_description( _("SVGAlib module") );
     set_capability( "video output", 0 );
     set_callbacks( Create, Destroy );
+    linked_with_a_crap_library_which_uses_atexit();
 vlc_module_end();
 
 /*****************************************************************************
index 318224dbecb4bd242240fa9e28d7f644dfef59f9..838903348826fe204a835b62f3815c74c691af5e 100644 (file)
@@ -2,7 +2,7 @@
  * modules.c : Builtin and plugin modules management functions
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: modules.c,v 1.91 2002/08/21 11:07:42 xav Exp $
+ * $Id: modules.c,v 1.92 2002/08/21 17:31:58 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          Ethan C. Baldridge <BaldridgeE@cadmus.com>
@@ -823,7 +823,10 @@ static int DeleteModule( module_t * p_module )
 #ifdef HAVE_DYNAMIC_PLUGINS
     if( !p_module->b_builtin )
     {
-        module_unload( p_module->handle );
+        if( p_module->b_unloadable )
+        {
+            module_unload( p_module->handle );
+        }
         UndupModule( p_module );
         free( p_module->psz_filename );
         free( p_module->psz_longname );