Changeset cdd517525b71b7b5390bfff52db183b09b00f7fe
- Timestamp:
- 05/10/08 11:57:12 (2 months ago)
- git-parent:
- Files:
-
- include/vlc_messages.h (modified) (3 diffs)
- modules/codec/ffmpeg/ffmpeg.c (modified) (1 diff)
- modules/demux/mkv.cpp (modified) (1 diff)
- modules/gui/beos/MessagesWindow.cpp (modified) (1 diff)
- modules/gui/macosx/intf.m (modified) (1 diff)
- modules/gui/ncurses.c (modified) (1 diff)
- modules/gui/qt4/qt4.cpp (modified) (1 diff)
- modules/gui/skins2/src/skin_main.cpp (modified) (1 diff)
- modules/gui/wince/wince.cpp (modified) (1 diff)
- modules/gui/wxwidgets/wxwidgets.cpp (modified) (1 diff)
- modules/misc/logger.c (modified) (1 diff)
- modules/misc/lua/vlc.h (modified) (1 diff)
- src/control/log.c (modified) (1 diff)
- src/libvlc.h (modified) (2 diffs)
- src/misc/messages.c (modified) (17 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
include/vlc_messages.h
r80ddb52 rcdd5175 67 67 #define VLC_MSG_DBG 3 68 68 69 #define MSG_QUEUE_NORMAL 070 #define MSG_QUEUE_HTTPD_ACCESS 171 72 69 /** 73 70 * Used by interface plugins which subscribe to the message bank. … … 85 82 * Prototypes 86 83 *****************************************************************************/ 87 VLC_EXPORT( void, __msg_Generic, ( vlc_object_t *, int, int, const char *, const char *, ... ) ATTRIBUTE_FORMAT( 5, 6) );88 VLC_EXPORT( void, __msg_GenericVa, ( vlc_object_t *, int, int,const char *, const char *, va_list args ) );89 #define msg_GenericVa(a, b, c, d, e ,f) __msg_GenericVa(VLC_OBJECT(a), b, c, d, e,f)84 VLC_EXPORT( void, __msg_Generic, ( vlc_object_t *, int, const char *, const char *, ... ) ATTRIBUTE_FORMAT( 4, 5 ) ); 85 VLC_EXPORT( void, __msg_GenericVa, ( vlc_object_t *, int, const char *, const char *, va_list args ) ); 86 #define msg_GenericVa(a, b, c, d, e) __msg_GenericVa(VLC_OBJECT(a), b, c, d, e) 90 87 VLC_EXPORT( void, __msg_Info, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) ); 91 88 VLC_EXPORT( void, __msg_Err, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) ); … … 94 91 95 92 #define msg_Info( p_this, ... ) \ 96 __msg_Generic( VLC_OBJECT(p_this), MSG_QUEUE_NORMAL,VLC_MSG_INFO, \93 __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_INFO, \ 97 94 MODULE_STRING, __VA_ARGS__ ) 98 95 #define msg_Err( p_this, ... ) \ 99 __msg_Generic( VLC_OBJECT(p_this), MSG_QUEUE_NORMAL,VLC_MSG_ERR, \96 __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_ERR, \ 100 97 MODULE_STRING, __VA_ARGS__ ) 101 98 #define msg_Warn( p_this, ... ) \ 102 __msg_Generic( VLC_OBJECT(p_this), MSG_QUEUE_NORMAL,VLC_MSG_WARN, \99 __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_WARN, \ 103 100 MODULE_STRING, __VA_ARGS__ ) 104 101 #define msg_Dbg( p_this, ... ) \ 105 __msg_Generic( VLC_OBJECT(p_this), MSG_QUEUE_NORMAL,VLC_MSG_DBG, \102 __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_DBG, \ 106 103 MODULE_STRING, __VA_ARGS__ ) 107 104 108 #define msg_Subscribe(a ,b) __msg_Subscribe(VLC_OBJECT(a),b)105 #define msg_Subscribe(a) __msg_Subscribe(VLC_OBJECT(a)) 109 106 #define msg_Unsubscribe(a,b) __msg_Unsubscribe(VLC_OBJECT(a),b) 110 VLC_EXPORT( msg_subscription_t*, __msg_Subscribe, ( vlc_object_t * , int) );107 VLC_EXPORT( msg_subscription_t*, __msg_Subscribe, ( vlc_object_t * ) ); 111 108 VLC_EXPORT( void, __msg_Unsubscribe, ( vlc_object_t *, msg_subscription_t * ) ); 112 109 modules/codec/ffmpeg/ffmpeg.c
r6300760 rcdd5175 448 448 snprintf( psz_new_format, strlen(psz_format) + strlen(psz_item_name) 449 449 + 18 + 5, "%s (%s@%p)", psz_format, p_avc->item_name(p_opaque), p_opaque ); 450 msg_GenericVa( p_this, MSG_QUEUE_NORMAL,i_vlc_level,450 msg_GenericVa( p_this, i_vlc_level, 451 451 MODULE_STRING, psz_new_format, va ); 452 452 free( psz_new_format ); modules/demux/mkv.cpp
r27d483e rcdd5175 504 504 psz_foo2[ 4 * i_level + 1 ] = ' '; 505 505 strcpy( &psz_foo2[ 4 * i_level + 2 ], psz_format ); 506 __msg_GenericVa( VLC_OBJECT(&demuxer), MSG_QUEUE_NORMAL,VLC_MSG_DBG, "mkv", psz_foo2, args );506 __msg_GenericVa( VLC_OBJECT(&demuxer),VLC_MSG_DBG, "mkv", psz_foo2, args ); 507 507 free( psz_foo2 ); 508 508 va_end( args ); modules/gui/beos/MessagesWindow.cpp
r6c52c72 rcdd5175 127 127 SetSizeLimits( 400, 2000, 200, 2000 ); 128 128 129 p_sub = msg_Subscribe( p_intf , MSG_QUEUE_NORMAL);129 p_sub = msg_Subscribe( p_intf ); 130 130 131 131 BRect rect, textRect; modules/gui/macosx/intf.m
r3ad6ea9 rcdd5175 108 108 109 109 p_intf->p_sys->o_sendport = [[NSPort port] retain]; 110 p_intf->p_sys->p_sub = msg_Subscribe( p_intf , MSG_QUEUE_NORMAL);110 p_intf->p_sys->p_sub = msg_Subscribe( p_intf ); 111 111 p_intf->b_play = true; 112 112 p_intf->pf_run = Run; modules/gui/ncurses.c
r2c73e8c rcdd5175 257 257 p_sys->i_box_plidx = 0; 258 258 p_sys->i_box_bidx = 0; 259 p_sys->p_sub = msg_Subscribe( p_intf , MSG_QUEUE_NORMAL);259 p_sys->p_sub = msg_Subscribe( p_intf ); 260 260 p_sys->b_color = var_CreateGetBool( p_intf, "color" ); 261 261 p_sys->b_color_started = false; modules/gui/qt4/qt4.cpp
r27d483e rcdd5175 234 234 235 235 p_intf->p_sys->p_playlist = pl_Yield( p_intf ); 236 p_intf->p_sys->p_sub = msg_Subscribe( p_intf , MSG_QUEUE_NORMAL);236 p_intf->p_sys->p_sub = msg_Subscribe( p_intf ); 237 237 238 238 /* We support play on start */ modules/gui/skins2/src/skin_main.cpp
r27d483e rcdd5175 96 96 97 97 // Suscribe to messages bank 98 p_intf->p_sys->p_sub = msg_Subscribe( p_intf , MSG_QUEUE_NORMAL);98 p_intf->p_sys->p_sub = msg_Subscribe( p_intf ); 99 99 100 100 p_intf->p_sys->p_input = NULL; modules/gui/wince/wince.cpp
r27d483e rcdd5175 117 117 118 118 // Suscribe to messages bank 119 p_intf->p_sys->p_sub = msg_Subscribe( p_intf , MSG_QUEUE_NORMAL);119 p_intf->p_sys->p_sub = msg_Subscribe( p_intf ); 120 120 121 121 // Misc init modules/gui/wxwidgets/wxwidgets.cpp
r27d483e rcdd5175 200 200 p_intf->pf_run = Run; 201 201 202 p_intf->p_sys->p_sub = msg_Subscribe( p_intf , MSG_QUEUE_NORMAL);202 p_intf->p_sys->p_sub = msg_Subscribe( p_intf ); 203 203 204 204 /* Initialize wxWidgets thread */ modules/misc/logger.c
r27d483e rcdd5175 292 292 } 293 293 294 p_intf->p_sys->p_sub = msg_Subscribe( p_intf , MSG_QUEUE_NORMAL);294 p_intf->p_sys->p_sub = msg_Subscribe( p_intf ); 295 295 p_intf->pf_run = Run; 296 296 modules/misc/lua/vlc.h
r6300760 rcdd5175 65 65 va_list ap; 66 66 va_start( ap, ppz_fmt ); 67 __msg_GenericVa( ( vlc_object_t *)p_this, MSG_QUEUE_NORMAL, 68 VLC_MSG_DBG, MODULE_STRING, 67 __msg_GenericVa( ( vlc_object_t *)p_this, VLC_MSG_DBG, MODULE_STRING, 69 68 ppz_fmt, ap ); 70 69 va_end( ap ); src/control/log.c
rc452d07 rcdd5175 70 70 71 71 p_log->p_instance = p_instance; 72 p_log->p_messages = msg_Subscribe(p_instance->p_libvlc_int , MSG_QUEUE_NORMAL);72 p_log->p_messages = msg_Subscribe(p_instance->p_libvlc_int); 73 73 74 74 if( !p_log->p_messages ) src/libvlc.h
r80ddb52 rcdd5175 64 64 */ 65 65 66 #define NB_QUEUES 267 68 66 typedef struct msg_queue_t 69 67 { 70 int i_id;71 72 68 /** Message queue lock */ 73 69 vlc_mutex_t lock; … … 95 91 { 96 92 vlc_mutex_t lock; 97 msg_queue_t queue s[NB_QUEUES];93 msg_queue_t queue; 98 94 } msg_bank_t; 99 95 src/misc/messages.c
r80ddb52 rcdd5175 67 67 #endif 68 68 69 #define QUEUE (i) priv->msg_bank.queues[i]69 #define QUEUE priv->msg_bank.queue 70 70 #define LOCK_BANK vlc_mutex_lock( &priv->msg_bank.lock ); 71 71 #define UNLOCK_BANK vlc_mutex_unlock( &priv->msg_bank.lock ); … … 74 74 * Local prototypes 75 75 *****************************************************************************/ 76 static void QueueMsg ( vlc_object_t *, int, int ,const char *,76 static void QueueMsg ( vlc_object_t *, int, const char *, 77 77 const char *, va_list ); 78 78 static void FlushMsg ( msg_queue_t * ); … … 87 87 libvlc_priv_t *priv = libvlc_priv (p_libvlc); 88 88 vlc_mutex_init( &priv->msg_bank.lock ); 89 90 for( int i = 0; i < 2; i++ ) 91 { 92 vlc_mutex_init( &QUEUE(i).lock ); 93 QUEUE(i).b_overflow = false; 94 QUEUE(i).i_id = i; 95 QUEUE(i).i_start = 0; 96 QUEUE(i).i_stop = 0; 97 QUEUE(i).i_sub = 0; 98 QUEUE(i).pp_sub = 0; 99 } 89 vlc_mutex_init( &QUEUE.lock ); 90 QUEUE.b_overflow = false; 91 QUEUE.i_start = 0; 92 QUEUE.i_stop = 0; 93 QUEUE.i_sub = 0; 94 QUEUE.pp_sub = 0; 100 95 101 96 #ifdef UNDER_CE 102 QUEUE (MSG_QUEUE_NORMAL).logfile =97 QUEUE.logfile = 103 98 CreateFile( L"vlc-log.txt", GENERIC_WRITE, 104 99 FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, 105 100 CREATE_ALWAYS, 0, NULL ); 106 SetFilePointer( QUEUE (MSG_QUEUE_NORMAL).logfile, 0, NULL, FILE_END );101 SetFilePointer( QUEUE.logfile, 0, NULL, FILE_END ); 107 102 #endif 108 103 } … … 114 109 { 115 110 libvlc_priv_t *priv = libvlc_priv (p_libvlc); 116 117 for( int i = 0 ; i < NB_QUEUES ; i++ ) 118 { 119 vlc_mutex_lock( &QUEUE(i).lock ); 120 FlushMsg( &QUEUE(i) ); 121 vlc_mutex_unlock( &QUEUE(i).lock ); 122 } 111 vlc_mutex_lock( &QUEUE.lock ); 112 FlushMsg( &QUEUE ); 113 vlc_mutex_unlock( &QUEUE.lock ); 123 114 } 124 115 … … 134 125 libvlc_priv_t *priv = libvlc_priv (p_libvlc); 135 126 136 for( int i = NB_QUEUES -1 ; i >= 0; i-- ) 137 { 138 if( QUEUE(i).i_sub ) 139 msg_Err( p_libvlc, "stale interface subscribers" ); 140 141 FlushMsg( &QUEUE(i) ); 127 if( QUEUE.i_sub ) 128 msg_Err( p_libvlc, "stale interface subscribers" ); 129 130 FlushMsg( &QUEUE ); 142 131 143 132 #ifdef UNDER_CE 144 if( i == MSG_QUEUE_NORMAL ) 145 CloseHandle( QUEUE(MSG_QUEUE_NORMAL).logfile ); 146 #endif 147 /* Destroy lock */ 148 vlc_mutex_destroy( &QUEUE(i).lock ); 149 } 133 CloseHandle( QUEUE.logfile ); 134 #endif 135 /* Destroy lock */ 136 vlc_mutex_destroy( &QUEUE.lock ); 150 137 vlc_mutex_destroy( &priv->msg_bank.lock); 151 138 } … … 154 141 * Subscribe to a message queue. 155 142 */ 156 msg_subscription_t *__msg_Subscribe( vlc_object_t *p_this , int i)143 msg_subscription_t *__msg_Subscribe( vlc_object_t *p_this ) 157 144 { 158 145 libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc); … … 162 149 return NULL; 163 150 164 assert( i < NB_QUEUES );165 166 151 LOCK_BANK; 167 vlc_mutex_lock( &QUEUE (i).lock );168 169 TAB_APPEND( QUEUE (i).i_sub, QUEUE(i).pp_sub, p_sub );170 171 p_sub->i_start = QUEUE (i).i_start;172 p_sub->pi_stop = &QUEUE (i).i_stop;173 p_sub->p_msg = QUEUE (i).msg;174 p_sub->p_lock = &QUEUE (i).lock;175 176 vlc_mutex_unlock( &QUEUE (i).lock );152 vlc_mutex_lock( &QUEUE.lock ); 153 154 TAB_APPEND( QUEUE.i_sub, QUEUE.pp_sub, p_sub ); 155 156 p_sub->i_start = QUEUE.i_start; 157 p_sub->pi_stop = &QUEUE.i_stop; 158 p_sub->p_msg = QUEUE.msg; 159 p_sub->p_lock = &QUEUE.lock; 160 161 vlc_mutex_unlock( &QUEUE.lock ); 177 162 UNLOCK_BANK; 178 163 … … 188 173 189 174 LOCK_BANK; 190 for( int i = 0 ; i< NB_QUEUES ; i++ ) 191 { 192 vlc_mutex_lock( &QUEUE(i).lock ); 193 for( int j = 0 ; j< QUEUE(i).i_sub ; j++ ) 194 { 195 if( QUEUE(i).pp_sub[j] == p_sub ) 196 { 197 REMOVE_ELEM( QUEUE(i).pp_sub, QUEUE(i).i_sub, j ); 198 free( p_sub ); 199 } 200 } 201 vlc_mutex_unlock( & QUEUE(i).lock ); 202 } 175 vlc_mutex_lock( &QUEUE.lock ); 176 for( int j = 0 ; j< QUEUE.i_sub ; j++ ) 177 { 178 if( QUEUE.pp_sub[j] == p_sub ) 179 { 180 REMOVE_ELEM( QUEUE.pp_sub, QUEUE.i_sub, j ); 181 free( p_sub ); 182 } 183 } 184 vlc_mutex_unlock( &QUEUE.lock ); 203 185 UNLOCK_BANK; 204 186 } … … 209 191 * These functions queue a message for later printing. 210 192 *****************************************************************************/ 211 void __msg_Generic( vlc_object_t *p_this, int i_queue, int i_type, 212 const char *psz_module, 193 void __msg_Generic( vlc_object_t *p_this, int i_type, const char *psz_module, 213 194 const char *psz_format, ... ) 214 195 { … … 216 197 217 198 va_start( args, psz_format ); 218 QueueMsg( p_this, i_ queue, i_type, psz_module, psz_format, args );199 QueueMsg( p_this, i_type, psz_module, psz_format, args ); 219 200 va_end( args ); 220 201 } 221 202 222 void __msg_GenericVa( vlc_object_t *p_this, int i_queue, 223 int i_type, const char *psz_module, 203 void __msg_GenericVa( vlc_object_t *p_this, int i_type, const char *psz_module, 224 204 const char *psz_format, va_list args ) 225 205 { 226 QueueMsg( p_this, i_ queue, i_type, psz_module, psz_format, args );206 QueueMsg( p_this, i_type, psz_module, psz_format, args ); 227 207 } 228 208 … … 233 213 va_list args; \ 234 214 va_start( args, psz_format ); \ 235 QueueMsg( p_this,MSG_QUEUE_NORMAL, FN_TYPE, "unknown", \ 236 psz_format, args ); \ 215 QueueMsg( p_this, FN_TYPE, "unknown", psz_format, args ); \ 237 216 va_end( args ); \ 238 217 } \ … … 265 244 * a warning. 266 245 */ 267 static void QueueMsg( vlc_object_t *p_this, int i_queue, int i_type, 268 const char *psz_module, 246 static void QueueMsg( vlc_object_t *p_this, int i_type, const char *psz_module, 269 247 const char *psz_format, va_list _args ) 270 248 { … … 411 389 #endif 412 390 413 assert( i_queue < NB_QUEUES );414 391 LOCK_BANK; 415 p_queue = &QUEUE (i_queue);392 p_queue = &QUEUE; 416 393 vlc_mutex_lock( &p_queue->lock ); 417 394 … … 440 417 p_queue->b_overflow = true; 441 418 442 if( p_queue->i_id == MSG_QUEUE_NORMAL ) 443 { 444 /* Put the overflow message in the queue */ 445 p_item = p_queue->msg + p_queue->i_stop; 446 p_queue->i_stop = (p_queue->i_stop + 1) % VLC_MSG_QSIZE; 447 448 p_item->i_type = VLC_MSG_WARN; 449 p_item->i_object_id = p_this->i_object_id; 450 p_item->psz_object_type = p_this->psz_object_type; 451 p_item->psz_module = strdup( "message" ); 452 p_item->psz_msg = strdup( "message queue overflowed" ); 453 p_item->psz_header = NULL; 454 455 PrintMsg( p_this, p_item ); 456 /* We print from a dummy item */ 457 p_item = &item; 458 } 419 /* Put the overflow message in the queue */ 420 p_item = p_queue->msg + p_queue->i_stop; 421 p_queue->i_stop = (p_queue->i_stop + 1) % VLC_MSG_QSIZE; 422 423 p_item->i_type = VLC_MSG_WARN; 424 p_item->i_object_id = p_this->i_object_id; 425 p_item->psz_object_type = p_this->psz_object_type; 426 p_item->psz_module = strdup( "message" ); 427 p_item->psz_msg = strdup( "message queue overflowed" ); 428 p_item->psz_header = NULL; 429 430 PrintMsg( p_this, p_item ); 431 /* We print from a dummy item */ 432 p_item = &item; 459 433 } 460 434 } … … 475 449 p_item->psz_header = psz_header; 476 450 477 if( p_queue->i_id == MSG_QUEUE_NORMAL ) 478 PrintMsg( p_this, p_item ); 451 PrintMsg( p_this, p_item ); 479 452 480 453 if( p_queue->b_overflow ) … … 576 549 577 550 #ifdef UNDER_CE 578 # define CE_WRITE(str) WriteFile( QUEUE (MSG_QUEUE_NORMAL).logfile, \551 # define CE_WRITE(str) WriteFile( QUEUE.logfile, \ 579 552 str, strlen(str), &i_dummy, NULL ); 580 553 CE_WRITE( p_item->psz_module ); … … 585 558 CE_WRITE( p_item->psz_msg ); 586 559 CE_WRITE( "\r\n" ); 587 FlushFileBuffers( QUEUE (MSG_QUEUE_NORMAL).logfile );560 FlushFileBuffers( QUEUE.logfile ); 588 561 589 562 #else
