Changeset 28ad2fd075be37cb4258af5806896ab042897c09

Show
Ignore:
Timestamp:
21/08/02 19:31:58 (6 years ago)
Author:
Sam Hocevar <sam@videolan.org>
git-committer:
Sam Hocevar <sam@videolan.org> 1029951118 +0000
git-parent:

[a5a565cb0b6d5b361d680928446b7a3c3dd0b26a]

git-author:
Sam Hocevar <sam@videolan.org> 1029951118 +0000
Message:
  • ./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.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • configure

    rb6aeeca r28ad2fd  
    81548154if test "x${enable_svgalib}" = "xyes" 
    81558155then 
    8156   BUILTINS="${BUILTINS} video_output/svgalib" 
     8156  PLUGINS="${PLUGINS} video_output/svgalib" 
    81578157  svgalib_LDFLAGS="${svgalib_LDFLAGS} -lvgagl -lvga" 
    81588158fi 
  • configure.in

    rb6aeeca r28ad2fd  
    14361436if test "x${enable_svgalib}" = "xyes" 
    14371437then 
    1438   BUILTINS="${BUILTINS} video_output/svgalib" 
     1438  PLUGINS="${PLUGINS} video_output/svgalib" 
    14391439  svgalib_LDFLAGS="${svgalib_LDFLAGS} -lvgagl -lvga" 
    14401440fi 
  • include/modules.h

    r5dc2da7 r28ad2fd  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: modules.h,v 1.60 2002/08/15 12:11:15 sam Exp $ 
     5 * $Id: modules.h,v 1.61 2002/08/21 17:31:58 sam Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    7272    u32   i_cpu;                                /* Required CPU capabilities */ 
    7373 
     74    vlc_bool_t b_unloadable;                          /* Can we be dlclosed? */ 
     75    vlc_bool_t b_reentrant;                             /* Are we reentrant? */ 
    7476    vlc_bool_t b_submodule;                          /* Is this a submodule? */ 
    7577 
  • include/modules_inner.h

    r005be13 r28ad2fd  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: modules_inner.h,v 1.30 2002/08/14 17:06:53 sam Exp $ 
     5 * $Id: modules_inner.h,v 1.31 2002/08/21 17:31:58 sam Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    8888        STORE_SYMBOLS;                                                        \ 
    8989        p_module->b_submodule = VLC_FALSE;                                    \ 
     90        p_module->b_unloadable = VLC_TRUE;                                    \ 
     91        p_module->b_reentrant = VLC_TRUE;                                     \ 
    9092        p_module->psz_object_name = MODULE_STRING;                            \ 
    9193        p_module->psz_longname = MODULE_STRING;                               \ 
     
    146148 
    147149#define set_description( desc )                                               \ 
    148     p_module->psz_longname = desc 
     150    p_submodule->psz_longname = desc 
    149151 
    150152#define set_capability( cap, score )                                          \ 
     
    158160    p_submodule->pf_activate = activate;                                      \ 
    159161    p_submodule->pf_deactivate = deactivate 
     162 
     163#define linked_with_a_crap_library_which_uses_atexit( )                       \ 
     164    p_module->b_unloadable = VLC_FALSE 
    160165 
    161166/* 
  • modules/misc/gtk_main.c

    ra5a565c r28ad2fd  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: gtk_main.c,v 1.3 2002/08/21 15:55:15 sam Exp $ 
     5 * $Id: gtk_main.c,v 1.4 2002/08/21 17:31:58 sam Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    5252    VLC_COMMON_MEMBERS 
    5353 
    54     /* XXX: Ugly kludge, see g_atexit */ 
    55     void ( *pf_callback[MAX_ATEXIT] ) ( void ); 
    56  
    5754} gtk_main_t; 
    5855 
     
    6057 * Local variables (mutex-protected). 
    6158 *****************************************************************************/ 
    62 static void **       pp_global_data = NULL; 
    6359static int           i_refcount = 0; 
    6460static gtk_main_t *  p_gtk_main = NULL; 
     
    6864 *****************************************************************************/ 
    6965vlc_module_begin(); 
    70     pp_global_data = p_module->p_vlc->pp_global_data; 
    7166    set_description( _("Gtk+ helper module") ); 
    7267    set_capability( "gtk_main", 100 ); 
     
    7671#endif 
    7772    set_callbacks( Open, Close ); 
     73    linked_with_a_crap_library_which_uses_atexit(); 
    7874vlc_module_end(); 
    79  
    80 /***************************************************************************** 
    81  * g_atexit: kludge to avoid the Gtk+ thread to segfault at exit 
    82  ***************************************************************************** 
    83  * gtk_init() makes several calls to g_atexit() which calls atexit() to 
    84  * register tidying callbacks to be called at program exit. Since the Gtk+ 
    85  * plugin is likely to be unloaded at program exit, we have to export this 
    86  * symbol to intercept the g_atexit() calls. Talk about crude hack. 
    87  *****************************************************************************/ 
    88 void g_atexit( GVoidFunc func ) 
    89 { 
    90     gtk_main_t *p_this; 
    91  
    92     int i_dummy; 
    93  
    94     if( pp_global_data == NULL ) 
    95     { 
    96         atexit( func ); 
    97         return; 
    98     } 
    99  
    100     p_this = (gtk_main_t *)*pp_global_data; 
    101     if( p_this == NULL ) 
    102     { 
    103         /* Looks like this atexit() call wasn't for us. */ 
    104         return; 
    105     } 
    106  
    107     for( i_dummy = 0; 
    108          i_dummy < MAX_ATEXIT && p_this->pf_callback[i_dummy] != NULL; 
    109          i_dummy++ ) 
    110     { 
    111         ; 
    112     } 
    113  
    114     if( i_dummy >= MAX_ATEXIT - 1 ) 
    115     { 
    116         msg_Err( p_this, "too many atexit() callbacks to register" ); 
    117         return; 
    118     } 
    119  
    120     p_this->pf_callback[i_dummy]     = func; 
    121     p_this->pf_callback[i_dummy + 1] = NULL; 
    122 } 
    12375 
    12476/***************************************************************************** 
     
    12779static int Open( vlc_object_t *p_this ) 
    12880{ 
    129     /* Initialize Gtk+ */ 
    130  
    13181    vlc_mutex_lock( p_this->p_vlc->p_global_lock ); 
    13282 
     
    14090 
    14191    p_gtk_main = vlc_object_create( p_this, sizeof(gtk_main_t) ); 
    142     p_gtk_main->pf_callback[0] = NULL; 
    14392 
    14493    /* Only initialize gthreads if it's the first time we do it */ 
     
    169118static void Close( vlc_object_t *p_this ) 
    170119{ 
    171     int i_dummy; 
    172  
    173120    vlc_mutex_lock( p_this->p_vlc->p_global_lock ); 
    174121 
     
    183130    gtk_main_quit(); 
    184131    vlc_thread_join( p_gtk_main ); 
    185  
    186     /* Launch stored callbacks */ 
    187     for( i_dummy = 0; 
    188          i_dummy < MAX_ATEXIT && p_gtk_main->pf_callback[i_dummy] != NULL; 
    189          i_dummy++ ) 
    190     { 
    191         p_gtk_main->pf_callback[i_dummy](); 
    192     } 
    193132 
    194133    vlc_object_destroy( p_gtk_main ); 
     
    219158    static int    i_args   = 1; 
    220159 
    221     /* gtk_init will register stuff with g_atexit, so we need to have 
    222      * the global lock if we want to be able to intercept the calls */ 
    223     *p_this->p_vlc->pp_global_data = p_gtk_main; 
    224  
    225160    /* FIXME: deprecated ? */ 
    226161    /* gdk_threads_init(); */ 
  • modules/video_output/svgalib.c

    rb6aeeca r28ad2fd  
    33 ***************************************************************************** 
    44 * Copyright (C) 2002 VideoLAN 
    5  * $Id: svgalib.c,v 1.1 2002/08/21 15:10:33 sam Exp $ 
     5 * $Id: svgalib.c,v 1.2 2002/08/21 17:31:58 sam Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    5454    set_capability( "video output", 0 ); 
    5555    set_callbacks( Create, Destroy ); 
     56    linked_with_a_crap_library_which_uses_atexit(); 
    5657vlc_module_end(); 
    5758 
  • src/misc/modules.c

    r18773d0 r28ad2fd  
    33 ***************************************************************************** 
    44 * Copyright (C) 2001 VideoLAN 
    5  * $Id: modules.c,v 1.91 2002/08/21 11:07:42 xav Exp $ 
     5 * $Id: modules.c,v 1.92 2002/08/21 17:31:58 sam Exp $ 
    66 * 
    77 * Authors: Samuel Hocevar <sam@zoy.org> 
     
    824824    if( !p_module->b_builtin ) 
    825825    { 
    826         module_unload( p_module->handle ); 
     826        if( p_module->b_unloadable ) 
     827        { 
     828            module_unload( p_module->handle ); 
     829        } 
    827830        UndupModule( p_module ); 
    828831        free( p_module->psz_filename );