Changeset 973f2f06b07e7773fd58abd3e5d4f89454dc7bc4

Show
Ignore:
Timestamp:
05/04/08 20:09:09 (3 months ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1209924549 +0300
git-parent:

[40f43d3256ee86695e0bf44adabb691707d5de01]

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

Privatize msg_bank

Files:

Legend:

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

    raebd6a4 r973f2f0  
    131131 
    132132/* Messages */ 
    133 typedef struct msg_bank_t msg_bank_t; 
    134 typedef struct msg_queue_t msg_queue_t; 
    135133typedef struct msg_subscription_t msg_subscription_t; 
    136134 
  • include/vlc_main.h

    re0a120e r973f2f0  
    5858    int                   i_last_input_id ;  ///< Last id of input item 
    5959 
    60     /* Messages */ 
    61     msg_bank_t             msg_bank;    ///< The message bank 
    62     int                    i_verbose;   ///< info messages 
    63     bool             b_color;     ///< color messages? 
    64  
    6560    /* Structure storing the action name / key associations */ 
    6661    struct hotkey 
  • include/vlc_messages.h

    r7a3fdc9 r973f2f0  
    8080#define MSG_QUEUE_NORMAL 0 
    8181#define MSG_QUEUE_HTTPD_ACCESS 1 
    82 #define NB_QUEUES 2 
    83  
    84 struct msg_queue_t 
    85 { 
    86     int                     i_id; 
    87  
    88     /** Message queue lock */ 
    89     vlc_mutex_t             lock; 
    90     bool              b_overflow; 
    91  
    92     /* Message queue */ 
    93     msg_item_t              msg[VLC_MSG_QSIZE];           /**< message queue */ 
    94     int i_start; 
    95     int i_stop; 
    96  
    97     /* Subscribers */ 
    98     int i_sub; 
    99     msg_subscription_t **pp_sub; 
    100  
    101     /* Logfile for WinCE */ 
    102 #ifdef UNDER_CE 
    103     FILE *logfile; 
    104 #endif 
    105 }; 
    106  
    107 /** 
    108  * Store all data requiered by messages interfaces. 
    109  */ 
    110 struct msg_bank_t 
    111 { 
    112     vlc_mutex_t             lock; 
    113     msg_queue_t             queues[NB_QUEUES]; 
    114 }; 
    11582 
    11683/** 
  • src/libvlc-common.c

    r40f43d3 r973f2f0  
    191191    psz_env = getenv( "VLC_VERBOSE" ); 
    192192    if( psz_env != NULL ) 
    193         p_libvlc->i_verbose = atoi( psz_env ); 
     193        priv->i_verbose = atoi( psz_env ); 
    194194    else 
    195         p_libvlc->i_verbose = 3; 
     195        priv->i_verbose = 3; 
    196196#if defined( HAVE_ISATTY ) && !defined( WIN32 ) 
    197     p_libvlc->b_color = isatty( 2 ); /* 2 is for stderr */ 
     197    priv->b_color = isatty( 2 ); /* 2 is for stderr */ 
    198198#else 
    199     p_libvlc->b_color = false; 
     199    priv->b_color = false; 
    200200#endif 
    201201 
     
    314314 
    315315    /* Will be re-done properly later on */ 
    316     p_libvlc->i_verbose = config_GetInt( p_libvlc, "verbose" ); 
     316    priv->i_verbose = config_GetInt( p_libvlc, "verbose" ); 
    317317 
    318318    /* Check for daemon mode */ 
     
    657657    var_Change( p_libvlc, "verbose", VLC_VAR_TRIGGER_CALLBACKS, NULL, NULL ); 
    658658 
    659     if( p_libvlc->b_color ) 
    660         p_libvlc->b_color = config_GetInt( p_libvlc, "color" ) > 0; 
     659    if( priv->b_color ) 
     660        priv->b_color = config_GetInt( p_libvlc, "color" ) > 0; 
    661661 
    662662    /* 
     
    19741974    if( new_val.i_int >= -1 ) 
    19751975    { 
    1976         p_libvlc->i_verbose = __MIN( new_val.i_int, 2 ); 
     1976        libvlc_priv (p_libvlc)->i_verbose = __MIN( new_val.i_int, 2 ); 
    19771977    } 
    19781978    return VLC_SUCCESS; 
  • src/libvlc.h

    re0a120e r973f2f0  
    7474 
    7575/* 
     76 * Message/logging stuff 
     77 */ 
     78 
     79#define NB_QUEUES 2 
     80 
     81typedef struct msg_queue_t 
     82{ 
     83    int                     i_id; 
     84 
     85    /** Message queue lock */ 
     86    vlc_mutex_t             lock; 
     87    bool              b_overflow; 
     88 
     89    /* Message queue */ 
     90    msg_item_t              msg[VLC_MSG_QSIZE];           /**< message queue */ 
     91    int i_start; 
     92    int i_stop; 
     93 
     94    /* Subscribers */ 
     95    int i_sub; 
     96    msg_subscription_t **pp_sub; 
     97 
     98    /* Logfile for WinCE */ 
     99#ifdef UNDER_CE 
     100    FILE *logfile; 
     101#endif 
     102} msg_queue_t; 
     103 
     104/** 
     105 * Store all data requiered by messages interfaces. 
     106 */ 
     107typedef struct msg_bank_t 
     108{ 
     109    vlc_mutex_t             lock; 
     110    msg_queue_t             queues[NB_QUEUES]; 
     111} msg_bank_t; 
     112 
     113/* 
    76114 * Unicode stuff 
    77115 */ 
     
    173211    vlc_mutex_t        config_lock; ///< config file lock 
    174212 
     213    /* Messages */ 
     214    msg_bank_t         msg_bank;    ///< The message bank 
     215    int                i_verbose;   ///< info messages 
     216    bool               b_color;     ///< color messages? 
     217 
     218    /* Timer stats */ 
    175219    vlc_mutex_t        timer_lock;  ///< Lock to protect timers 
    176220    counter_t        **pp_timers;   ///< Array of all timers 
  • src/misc/messages.c

    r6da90a1 r973f2f0  
    6767#endif 
    6868 
    69 #define QUEUE(i) p_this->p_libvlc->msg_bank.queues[i] 
    70 #define LOCK_BANK vlc_mutex_lock( &p_this->p_libvlc->msg_bank.lock ); 
    71 #define UNLOCK_BANK vlc_mutex_unlock( &p_this->p_libvlc->msg_bank.lock ); 
     69#define QUEUE(i) priv->msg_bank.queues[i] 
     70#define LOCK_BANK vlc_mutex_lock( &priv->msg_bank.lock ); 
     71#define UNLOCK_BANK vlc_mutex_unlock( &priv->msg_bank.lock ); 
    7272 
    7373/***************************************************************************** 
     
    8585void __msg_Create( vlc_object_t *p_this ) 
    8686{ 
    87     int i
    88     vlc_mutex_init( &(p_this->p_libvlc->msg_bank.lock) ); 
    89  
    90     for( i = 0; i < 2; i++ ) 
     87    libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc)
     88    vlc_mutex_init( &priv->msg_bank.lock ); 
     89 
     90    for( int i = 0; i < 2; i++ ) 
    9191    { 
    9292         vlc_mutex_init( &QUEUE(i).lock ); 
     
    113113void __msg_Flush( vlc_object_t *p_this ) 
    114114{ 
    115     int i; 
    116     for( i = 0 ; i < NB_QUEUES ; i++ ) 
     115    libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc); 
     116 
     117    for( int i = 0 ; i < NB_QUEUES ; i++ ) 
    117118    { 
    118119        vlc_mutex_lock( &QUEUE(i).lock ); 
     
    131132void __msg_Destroy( vlc_object_t *p_this ) 
    132133{ 
    133     int i; 
    134     for( i = NB_QUEUES -1 ; i >= 0;  i-- ) 
     134    libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc); 
     135 
     136    for( int i = NB_QUEUES -1 ; i >= 0;  i-- ) 
    135137    { 
    136138        if( QUEUE(i).i_sub ) 
     
    146148        vlc_mutex_destroy( &QUEUE(i).lock ); 
    147149    } 
    148     vlc_mutex_destroy( &(p_this->p_libvlc->msg_bank.lock) ); 
     150    vlc_mutex_destroy( &priv->msg_bank.lock); 
    149151} 
    150152 
     
    154156msg_subscription_t *__msg_Subscribe( vlc_object_t *p_this, int i ) 
    155157{ 
     158    libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc); 
    156159    msg_subscription_t *p_sub = malloc( sizeof( msg_subscription_t ) ); 
     160 
     161    if (p_sub == NULL) 
     162        return NULL; 
    157163 
    158164    assert( i < NB_QUEUES ); 
     
    179185void __msg_Unsubscribe( vlc_object_t *p_this, msg_subscription_t *p_sub ) 
    180186{ 
    181     int i,j
     187    libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc)
    182188 
    183189    LOCK_BANK; 
    184     for( i = 0 ; i< NB_QUEUES ; i++ ) 
     190    for( int i = 0 ; i< NB_QUEUES ; i++ ) 
    185191    { 
    186192        vlc_mutex_lock( &QUEUE(i).lock ); 
    187         for( j = 0 ; j< QUEUE(i).i_sub ; j++ ) 
     193        for( int j = 0 ; j< QUEUE(i).i_sub ; j++ ) 
    188194        { 
    189195            if( QUEUE(i).pp_sub[j] == p_sub ) 
     
    263269                      const char *psz_format, va_list _args ) 
    264270{ 
     271    libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc); 
    265272    int         i_header_size;             /* Size of the additionnal header */ 
    266273    vlc_object_t *p_obj; 
     
    557564    static const char *ppsz_color[4] = { WHITE, RED, YELLOW, GRAY }; 
    558565    const char *psz_object; 
     566    libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc); 
    559567    int i_type = p_item->i_type; 
    560568 
     
    562570    { 
    563571        case VLC_MSG_ERR: 
    564             if( p_this->p_libvlc->i_verbose < 0 ) return; 
     572            if( priv->i_verbose < 0 ) return; 
    565573            break; 
    566574        case VLC_MSG_INFO: 
    567             if( p_this->p_libvlc->i_verbose < 0 ) return; 
     575            if( priv->i_verbose < 0 ) return; 
    568576            break; 
    569577        case VLC_MSG_WARN: 
    570             if( p_this->p_libvlc->i_verbose < 1 ) return; 
     578            if( priv->i_verbose < 1 ) return; 
    571579            break; 
    572580        case VLC_MSG_DBG: 
    573             if( p_this->p_libvlc->i_verbose < 2 ) return; 
     581            if( priv->i_verbose < 2 ) return; 
    574582            break; 
    575583    } 
     
    591599#else 
    592600    /* Send the message to stderr */ 
    593     if( p_this->p_libvlc->b_color ) 
     601    if( priv->b_color ) 
    594602    { 
    595603        if( p_item->psz_header )