Commit 28ad2fd0 authored by Sam Hocevar's avatar Sam Hocevar

* ./src/misc/modules.c: if a plugin requested not to be unloaded, then we

    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.
parent a5a565cb
...@@ -8153,7 +8153,7 @@ fi ...@@ -8153,7 +8153,7 @@ fi
if test "x${enable_svgalib}" = "xyes" if test "x${enable_svgalib}" = "xyes"
then then
BUILTINS="${BUILTINS} video_output/svgalib" PLUGINS="${PLUGINS} video_output/svgalib"
svgalib_LDFLAGS="${svgalib_LDFLAGS} -lvgagl -lvga" svgalib_LDFLAGS="${svgalib_LDFLAGS} -lvgagl -lvga"
fi fi
......
...@@ -1435,7 +1435,7 @@ AC_ARG_ENABLE(svgalib, ...@@ -1435,7 +1435,7 @@ AC_ARG_ENABLE(svgalib,
[ --enable-svgalib SVGAlib support (default disabled)]) [ --enable-svgalib SVGAlib support (default disabled)])
if test "x${enable_svgalib}" = "xyes" if test "x${enable_svgalib}" = "xyes"
then then
BUILTINS="${BUILTINS} video_output/svgalib" PLUGINS="${PLUGINS} video_output/svgalib"
svgalib_LDFLAGS="${svgalib_LDFLAGS} -lvgagl -lvga" svgalib_LDFLAGS="${svgalib_LDFLAGS} -lvgagl -lvga"
fi fi
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* modules.h : Module management functions. * modules.h : Module management functions.
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -71,6 +71,8 @@ struct module_t ...@@ -71,6 +71,8 @@ struct module_t
int i_score; /* Score for each capability */ int i_score; /* Score for each capability */
u32 i_cpu; /* Required CPU capabilities */ 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? */ vlc_bool_t b_submodule; /* Is this a submodule? */
/* Callbacks */ /* Callbacks */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* modules_inner.h : Macros used from within a module. * modules_inner.h : Macros used from within a module.
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -87,6 +87,8 @@ ...@@ -87,6 +87,8 @@
module_config_t p_config[ 100 ]; \ module_config_t p_config[ 100 ]; \
STORE_SYMBOLS; \ STORE_SYMBOLS; \
p_module->b_submodule = VLC_FALSE; \ 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_object_name = MODULE_STRING; \
p_module->psz_longname = MODULE_STRING; \ p_module->psz_longname = MODULE_STRING; \
p_module->pp_shortcuts[ 0 ] = MODULE_STRING; \ p_module->pp_shortcuts[ 0 ] = MODULE_STRING; \
...@@ -145,7 +147,7 @@ ...@@ -145,7 +147,7 @@
i_shortcut++ i_shortcut++
#define set_description( desc ) \ #define set_description( desc ) \
p_module->psz_longname = desc p_submodule->psz_longname = desc
#define set_capability( cap, score ) \ #define set_capability( cap, score ) \
p_submodule->psz_capability = cap; \ p_submodule->psz_capability = cap; \
...@@ -158,6 +160,9 @@ ...@@ -158,6 +160,9 @@
p_submodule->pf_activate = activate; \ p_submodule->pf_activate = activate; \
p_submodule->pf_deactivate = deactivate 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, * module_activate: this function is called before functions can be accessed,
* we do allocation tasks here, and maybe additional stuff such as large * we do allocation tasks here, and maybe additional stuff such as large
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk_main.c : Gtk+ wrapper for gtk_main * gtk_main.c : Gtk+ wrapper for gtk_main
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -51,15 +51,11 @@ typedef struct gtk_main_t ...@@ -51,15 +51,11 @@ typedef struct gtk_main_t
{ {
VLC_COMMON_MEMBERS VLC_COMMON_MEMBERS
/* XXX: Ugly kludge, see g_atexit */
void ( *pf_callback[MAX_ATEXIT] ) ( void );
} gtk_main_t; } gtk_main_t;
/***************************************************************************** /*****************************************************************************
* Local variables (mutex-protected). * Local variables (mutex-protected).
*****************************************************************************/ *****************************************************************************/
static void ** pp_global_data = NULL;
static int i_refcount = 0; static int i_refcount = 0;
static gtk_main_t * p_gtk_main = NULL; static gtk_main_t * p_gtk_main = NULL;
...@@ -67,7 +63,6 @@ static gtk_main_t * p_gtk_main = NULL; ...@@ -67,7 +63,6 @@ static gtk_main_t * p_gtk_main = NULL;
* Module descriptor * Module descriptor
*****************************************************************************/ *****************************************************************************/
vlc_module_begin(); vlc_module_begin();
pp_global_data = p_module->p_vlc->pp_global_data;
set_description( _("Gtk+ helper module") ); set_description( _("Gtk+ helper module") );
set_capability( "gtk_main", 100 ); set_capability( "gtk_main", 100 );
add_shortcut( "gtk" ); add_shortcut( "gtk" );
...@@ -75,59 +70,14 @@ vlc_module_begin(); ...@@ -75,59 +70,14 @@ vlc_module_begin();
add_shortcut( "gnome" ); add_shortcut( "gnome" );
#endif #endif
set_callbacks( Open, Close ); set_callbacks( Open, Close );
linked_with_a_crap_library_which_uses_atexit();
vlc_module_end(); 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 * Open: initialize and create window
*****************************************************************************/ *****************************************************************************/
static int Open( vlc_object_t *p_this ) static int Open( vlc_object_t *p_this )
{ {
/* Initialize Gtk+ */
vlc_mutex_lock( p_this->p_vlc->p_global_lock ); vlc_mutex_lock( p_this->p_vlc->p_global_lock );
if( i_refcount > 0 ) if( i_refcount > 0 )
...@@ -139,7 +89,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -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 = 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 */ /* Only initialize gthreads if it's the first time we do it */
if( !g_thread_supported() ) if( !g_thread_supported() )
...@@ -168,8 +117,6 @@ static int Open( vlc_object_t *p_this ) ...@@ -168,8 +117,6 @@ static int Open( vlc_object_t *p_this )
*****************************************************************************/ *****************************************************************************/
static void Close( 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 ); vlc_mutex_lock( p_this->p_vlc->p_global_lock );
i_refcount--; i_refcount--;
...@@ -183,14 +130,6 @@ static void Close( vlc_object_t *p_this ) ...@@ -183,14 +130,6 @@ static void Close( vlc_object_t *p_this )
gtk_main_quit(); gtk_main_quit();
vlc_thread_join( p_gtk_main ); 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 ); vlc_object_destroy( p_gtk_main );
p_gtk_main = NULL; p_gtk_main = NULL;
...@@ -218,10 +157,6 @@ static void GtkMain( vlc_object_t *p_this ) ...@@ -218,10 +157,6 @@ static void GtkMain( vlc_object_t *p_this )
#endif #endif
static int i_args = 1; 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 ? */ /* FIXME: deprecated ? */
/* gdk_threads_init(); */ /* gdk_threads_init(); */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* svgalib.c : SVGAlib plugin for vlc * svgalib.c : SVGAlib plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -53,6 +53,7 @@ vlc_module_begin(); ...@@ -53,6 +53,7 @@ vlc_module_begin();
set_description( _("SVGAlib module") ); set_description( _("SVGAlib module") );
set_capability( "video output", 0 ); set_capability( "video output", 0 );
set_callbacks( Create, Destroy ); set_callbacks( Create, Destroy );
linked_with_a_crap_library_which_uses_atexit();
vlc_module_end(); vlc_module_end();
/***************************************************************************** /*****************************************************************************
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* modules.c : Builtin and plugin modules management functions * modules.c : Builtin and plugin modules management functions
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * 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> * Authors: Samuel Hocevar <sam@zoy.org>
* Ethan C. Baldridge <BaldridgeE@cadmus.com> * Ethan C. Baldridge <BaldridgeE@cadmus.com>
...@@ -823,7 +823,10 @@ static int DeleteModule( module_t * p_module ) ...@@ -823,7 +823,10 @@ static int DeleteModule( module_t * p_module )
#ifdef HAVE_DYNAMIC_PLUGINS #ifdef HAVE_DYNAMIC_PLUGINS
if( !p_module->b_builtin ) if( !p_module->b_builtin )
{ {
module_unload( p_module->handle ); if( p_module->b_unloadable )
{
module_unload( p_module->handle );
}
UndupModule( p_module ); UndupModule( p_module );
free( p_module->psz_filename ); free( p_module->psz_filename );
free( p_module->psz_longname ); free( p_module->psz_longname );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment