Changeset c07b1d0c2b8d9ec8afb3e2d1052b71b98baf41b7

Show
Ignore:
Timestamp:
05/03/08 11:24:05 (4 months ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1209806645 +0300
git-parent:

[4db976d9a6c11ddcc0ec438c836bdedf54137fa3]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1209806471 +0300
Message:

Hide global object within the thread and object subsystem

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_threads_funcs.h

    r4dc02f7 rc07b1d0  
    5252 
    5353/***************************************************************************** 
    54  * vlc_threads_init: initialize threads system 
    55  *****************************************************************************/ 
    56 #define vlc_threads_init( P_THIS )                                          \ 
    57     __vlc_threads_init( VLC_OBJECT(P_THIS) ) 
    58  
    59 /***************************************************************************** 
    60  * vlc_threads_end: deinitialize threads system 
    61  *****************************************************************************/ 
    62 #define vlc_threads_end( P_THIS )                                           \ 
    63     __vlc_threads_end( VLC_OBJECT(P_THIS) ) 
    64  
    65 /***************************************************************************** 
    6654 * vlc_mutex_init: initialize a mutex 
    6755 *****************************************************************************/ 
  • src/libvlc-common.c

    r50e969e rc07b1d0  
    9999 * The evil global variable. We handle it with care, don't worry. 
    100100 *****************************************************************************/ 
    101 static libvlc_global_data_t   libvlc_global; 
    102 static libvlc_global_data_t *p_libvlc_global = &libvlc_global; 
    103101static libvlc_int_t *    p_static_vlc = NULL; 
    104102static volatile unsigned int i_instances = 0; 
     
    128126 
    129127static void InitDeviceValues( libvlc_int_t * ); 
    130  
    131 libvlc_global_data_t *vlc_global( void ) 
    132 { 
    133     return p_libvlc_global; 
    134 } 
    135128 
    136129/***************************************************************************** 
     
    157150    /* vlc_threads_init *must* be the first internal call! No other call is 
    158151     * allowed before the thread system has been initialized. */ 
    159     if( vlc_threads_init( p_libvlc_global )
     152    if (vlc_threads_init ()
    160153        return NULL; 
    161154 
     155    libvlc_global_data_t *p_libvlc_global = vlc_global(); 
    162156    /* Now that the thread system is initialized, we don't have much, but 
    163157     * at least we have variables */ 
     
    231225                         const char *ppsz_argv[] ) 
    232226{ 
     227    libvlc_global_data_t *p_libvlc_global = vlc_global(); 
    233228    char         p_capabilities[200]; 
    234229    char *       p_tmp = NULL; 
     
    11091104     * The number of initializations of the thread system is counted, we 
    11101105     * can call this each time */ 
    1111     vlc_threads_end( p_libvlc_global ); 
     1106    vlc_threads_end (); 
    11121107 
    11131108    return VLC_SUCCESS; 
     
    11371132 
    11381133#ifndef WIN32 
    1139     if( p_libvlc_global->b_daemon && b_block && !psz_module ) 
     1134    if( vlc_global()->b_daemon && b_block && !psz_module ) 
    11401135    { 
    11411136        /* Daemon mode hack. 
  • src/libvlc.h

    r0d7bc73 rc07b1d0  
    5757 * Threads subsystem 
    5858 */ 
    59 int __vlc_threads_init( vlc_object_t * ); 
    60 int __vlc_threads_end( vlc_object_t * ); 
     59int vlc_threads_init( void ); 
     60void vlc_threads_end( void ); 
    6161 
    6262/** The global thread var for msg stack context 
  • src/misc/threads.c

    r23afa49 rc07b1d0  
    4646 *****************************************************************************/ 
    4747static volatile unsigned i_initializations = 0; 
     48 
     49#if defined( UNDER_CE ) 
     50#elif defined( WIN32 ) 
     51#elif defined( HAVE_KERNEL_SCHEDULER_H ) 
     52#elif defined( LIBVLC_USE_PTHREAD ) 
     53static pthread_mutex_t once_mutex = PTHREAD_MUTEX_INITIALIZER; 
     54#endif 
     55 
     56/** 
     57 * Global process-wide VLC object. 
     58 * Contains inter-instance data, such as the module cache and global mutexes. 
     59 */ 
    4860static vlc_object_t *p_root; 
    49  
    50 #if defined( UNDER_CE ) 
    51 #elif defined( WIN32 ) 
    52 #elif defined( HAVE_KERNEL_SCHEDULER_H ) 
    53 #elif defined( LIBVLC_USE_PTHREAD ) 
    54 static pthread_mutex_t once_mutex = PTHREAD_MUTEX_INITIALIZER; 
    55 #endif 
     61static libvlc_global_data_t   libvlc_global; 
     62 
     63libvlc_global_data_t *vlc_global( void ) 
     64
     65    assert( i_initializations > 0 ); 
     66    return &libvlc_global; 
     67
     68 
    5669 
    5770vlc_threadvar_t msg_context_global_key; 
     
    116129 * and thus do not guarantee the complete reentrancy. 
    117130 *****************************************************************************/ 
    118 int __vlc_threads_init( vlc_object_t *p_this ) 
    119 
    120     libvlc_global_data_t *p_libvlc_global = (libvlc_global_data_t *)p_this; 
     131int vlc_threads_init( void ) 
     132
    121133    int i_ret = VLC_SUCCESS; 
    122134 
     
    133145    { 
    134146        /* We should be safe now. Do all the initialization stuff we want. */ 
    135         p_libvlc_global->b_ready = false; 
    136  
    137         p_root = vlc_custom_create( VLC_OBJECT(p_libvlc_global), 0, 
     147        libvlc_global.b_ready = false; 
     148 
     149        p_root = vlc_custom_create( VLC_OBJECT(&libvlc_global), 0, 
    138150                                    VLC_OBJECT_GLOBAL, "global" ); 
    139151        if( p_root == NULL ) 
     
    164176 * FIXME: This function is far from being threadsafe. 
    165177 *****************************************************************************/ 
    166 int __vlc_threads_end( vlc_object_t *p_this ) 
    167 
    168     (void)p_this; 
     178void vlc_threads_end( void ) 
     179
    169180#if defined( UNDER_CE ) 
    170181#elif defined( WIN32 ) 
     
    184195    pthread_mutex_unlock( &once_mutex ); 
    185196#endif 
    186     return VLC_SUCCESS; 
    187197} 
    188198