Changeset 973f2f06b07e7773fd58abd3e5d4f89454dc7bc4
- 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
| raebd6a4 |
r973f2f0 |
|
| 131 | 131 | |
|---|
| 132 | 132 | /* Messages */ |
|---|
| 133 | | typedef struct msg_bank_t msg_bank_t; |
|---|
| 134 | | typedef struct msg_queue_t msg_queue_t; |
|---|
| 135 | 133 | typedef struct msg_subscription_t msg_subscription_t; |
|---|
| 136 | 134 | |
|---|
| re0a120e |
r973f2f0 |
|
| 58 | 58 | int i_last_input_id ; ///< Last id of input item |
|---|
| 59 | 59 | |
|---|
| 60 | | /* Messages */ |
|---|
| 61 | | msg_bank_t msg_bank; ///< The message bank |
|---|
| 62 | | int i_verbose; ///< info messages |
|---|
| 63 | | bool b_color; ///< color messages? |
|---|
| 64 | | |
|---|
| 65 | 60 | /* Structure storing the action name / key associations */ |
|---|
| 66 | 61 | struct hotkey |
|---|
| r7a3fdc9 |
r973f2f0 |
|
| 80 | 80 | #define MSG_QUEUE_NORMAL 0 |
|---|
| 81 | 81 | #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 | | }; |
|---|
| 115 | 82 | |
|---|
| 116 | 83 | /** |
|---|
| r40f43d3 |
r973f2f0 |
|
| 191 | 191 | psz_env = getenv( "VLC_VERBOSE" ); |
|---|
| 192 | 192 | if( psz_env != NULL ) |
|---|
| 193 | | p_libvlc->i_verbose = atoi( psz_env ); |
|---|
| | 193 | priv->i_verbose = atoi( psz_env ); |
|---|
| 194 | 194 | else |
|---|
| 195 | | p_libvlc->i_verbose = 3; |
|---|
| | 195 | priv->i_verbose = 3; |
|---|
| 196 | 196 | #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 */ |
|---|
| 198 | 198 | #else |
|---|
| 199 | | p_libvlc->b_color = false; |
|---|
| | 199 | priv->b_color = false; |
|---|
| 200 | 200 | #endif |
|---|
| 201 | 201 | |
|---|
| … | … | |
| 314 | 314 | |
|---|
| 315 | 315 | /* 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" ); |
|---|
| 317 | 317 | |
|---|
| 318 | 318 | /* Check for daemon mode */ |
|---|
| … | … | |
| 657 | 657 | var_Change( p_libvlc, "verbose", VLC_VAR_TRIGGER_CALLBACKS, NULL, NULL ); |
|---|
| 658 | 658 | |
|---|
| 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; |
|---|
| 661 | 661 | |
|---|
| 662 | 662 | /* |
|---|
| … | … | |
| 1974 | 1974 | if( new_val.i_int >= -1 ) |
|---|
| 1975 | 1975 | { |
|---|
| 1976 | | p_libvlc->i_verbose = __MIN( new_val.i_int, 2 ); |
|---|
| | 1976 | libvlc_priv (p_libvlc)->i_verbose = __MIN( new_val.i_int, 2 ); |
|---|
| 1977 | 1977 | } |
|---|
| 1978 | 1978 | return VLC_SUCCESS; |
|---|
| re0a120e |
r973f2f0 |
|
| 74 | 74 | |
|---|
| 75 | 75 | /* |
|---|
| | 76 | * Message/logging stuff |
|---|
| | 77 | */ |
|---|
| | 78 | |
|---|
| | 79 | #define NB_QUEUES 2 |
|---|
| | 80 | |
|---|
| | 81 | typedef 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 | */ |
|---|
| | 107 | typedef struct msg_bank_t |
|---|
| | 108 | { |
|---|
| | 109 | vlc_mutex_t lock; |
|---|
| | 110 | msg_queue_t queues[NB_QUEUES]; |
|---|
| | 111 | } msg_bank_t; |
|---|
| | 112 | |
|---|
| | 113 | /* |
|---|
| 76 | 114 | * Unicode stuff |
|---|
| 77 | 115 | */ |
|---|
| … | … | |
| 173 | 211 | vlc_mutex_t config_lock; ///< config file lock |
|---|
| 174 | 212 | |
|---|
| | 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 */ |
|---|
| 175 | 219 | vlc_mutex_t timer_lock; ///< Lock to protect timers |
|---|
| 176 | 220 | counter_t **pp_timers; ///< Array of all timers |
|---|
| r6da90a1 |
r973f2f0 |
|
| 67 | 67 | #endif |
|---|
| 68 | 68 | |
|---|
| 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 ); |
|---|
| 72 | 72 | |
|---|
| 73 | 73 | /***************************************************************************** |
|---|
| … | … | |
| 85 | 85 | void __msg_Create( vlc_object_t *p_this ) |
|---|
| 86 | 86 | { |
|---|
| 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++ ) |
|---|
| 91 | 91 | { |
|---|
| 92 | 92 | vlc_mutex_init( &QUEUE(i).lock ); |
|---|
| … | … | |
| 113 | 113 | void __msg_Flush( vlc_object_t *p_this ) |
|---|
| 114 | 114 | { |
|---|
| 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++ ) |
|---|
| 117 | 118 | { |
|---|
| 118 | 119 | vlc_mutex_lock( &QUEUE(i).lock ); |
|---|
| … | … | |
| 131 | 132 | void __msg_Destroy( vlc_object_t *p_this ) |
|---|
| 132 | 133 | { |
|---|
| 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-- ) |
|---|
| 135 | 137 | { |
|---|
| 136 | 138 | if( QUEUE(i).i_sub ) |
|---|
| … | … | |
| 146 | 148 | vlc_mutex_destroy( &QUEUE(i).lock ); |
|---|
| 147 | 149 | } |
|---|
| 148 | | vlc_mutex_destroy( &(p_this->p_libvlc->msg_bank.lock) ); |
|---|
| | 150 | vlc_mutex_destroy( &priv->msg_bank.lock); |
|---|
| 149 | 151 | } |
|---|
| 150 | 152 | |
|---|
| … | … | |
| 154 | 156 | msg_subscription_t *__msg_Subscribe( vlc_object_t *p_this, int i ) |
|---|
| 155 | 157 | { |
|---|
| | 158 | libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc); |
|---|
| 156 | 159 | msg_subscription_t *p_sub = malloc( sizeof( msg_subscription_t ) ); |
|---|
| | 160 | |
|---|
| | 161 | if (p_sub == NULL) |
|---|
| | 162 | return NULL; |
|---|
| 157 | 163 | |
|---|
| 158 | 164 | assert( i < NB_QUEUES ); |
|---|
| … | … | |
| 179 | 185 | void __msg_Unsubscribe( vlc_object_t *p_this, msg_subscription_t *p_sub ) |
|---|
| 180 | 186 | { |
|---|
| 181 | | int i,j; |
|---|
| | 187 | libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc); |
|---|
| 182 | 188 | |
|---|
| 183 | 189 | LOCK_BANK; |
|---|
| 184 | | for( i = 0 ; i< NB_QUEUES ; i++ ) |
|---|
| | 190 | for( int i = 0 ; i< NB_QUEUES ; i++ ) |
|---|
| 185 | 191 | { |
|---|
| 186 | 192 | 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++ ) |
|---|
| 188 | 194 | { |
|---|
| 189 | 195 | if( QUEUE(i).pp_sub[j] == p_sub ) |
|---|
| … | … | |
| 263 | 269 | const char *psz_format, va_list _args ) |
|---|
| 264 | 270 | { |
|---|
| | 271 | libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc); |
|---|
| 265 | 272 | int i_header_size; /* Size of the additionnal header */ |
|---|
| 266 | 273 | vlc_object_t *p_obj; |
|---|
| … | … | |
| 557 | 564 | static const char *ppsz_color[4] = { WHITE, RED, YELLOW, GRAY }; |
|---|
| 558 | 565 | const char *psz_object; |
|---|
| | 566 | libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc); |
|---|
| 559 | 567 | int i_type = p_item->i_type; |
|---|
| 560 | 568 | |
|---|
| … | … | |
| 562 | 570 | { |
|---|
| 563 | 571 | case VLC_MSG_ERR: |
|---|
| 564 | | if( p_this->p_libvlc->i_verbose < 0 ) return; |
|---|
| | 572 | if( priv->i_verbose < 0 ) return; |
|---|
| 565 | 573 | break; |
|---|
| 566 | 574 | case VLC_MSG_INFO: |
|---|
| 567 | | if( p_this->p_libvlc->i_verbose < 0 ) return; |
|---|
| | 575 | if( priv->i_verbose < 0 ) return; |
|---|
| 568 | 576 | break; |
|---|
| 569 | 577 | case VLC_MSG_WARN: |
|---|
| 570 | | if( p_this->p_libvlc->i_verbose < 1 ) return; |
|---|
| | 578 | if( priv->i_verbose < 1 ) return; |
|---|
| 571 | 579 | break; |
|---|
| 572 | 580 | case VLC_MSG_DBG: |
|---|
| 573 | | if( p_this->p_libvlc->i_verbose < 2 ) return; |
|---|
| | 581 | if( priv->i_verbose < 2 ) return; |
|---|
| 574 | 582 | break; |
|---|
| 575 | 583 | } |
|---|
| … | … | |
| 591 | 599 | #else |
|---|
| 592 | 600 | /* Send the message to stderr */ |
|---|
| 593 | | if( p_this->p_libvlc->b_color ) |
|---|
| | 601 | if( priv->b_color ) |
|---|
| 594 | 602 | { |
|---|
| 595 | 603 | if( p_item->psz_header ) |
|---|