1 /*****************************************************************************
2 * messages.h: messages interface
3 * This library provides basic functions for threads to interact with user
4 * interface, such as message output.
5 *****************************************************************************
6 * Copyright (C) 1999, 2000, 2001, 2002 the VideoLAN team
9 * Authors: Vincent Seguin <seguin@via.ecp.fr>
10 * Samuel Hocevar <sam@zoy.org>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
25 *****************************************************************************/
29 * \defgroup messages Messages
30 * This library provides basic functions for threads to interact with user
31 * interface, such as message output.
38 * Store a single message.
42 int i_type; /**< message type, see below */
46 char * psz_msg; /**< the message itself */
48 mtime_t date; /**< Message date */
52 /** standard messages */
53 #define VLC_MSG_INFO 0
56 /** warning messages */
57 #define VLC_MSG_WARN 2
61 #define MSG_QUEUE_NORMAL 0
62 #define MSG_QUEUE_HTTPD_ACCESS 1
65 * Store all data requiered by messages interfaces.
71 msg_queue_t **pp_queues;
78 /** Message queue lock */
80 vlc_bool_t b_overflow;
83 msg_item_t msg[VLC_MSG_QSIZE]; /**< message queue */
89 msg_subscription_t **pp_sub;
91 /* Logfile for WinCE */
98 * Used by interface plugins which subscribe to the message bank.
100 struct msg_subscription_t
109 /*****************************************************************************
111 *****************************************************************************/
112 VLC_EXPORT( void, __msg_Generic, ( vlc_object_t *, int, int, const char *, const char *, ... ) ATTRIBUTE_FORMAT( 5, 6 ) );
113 VLC_EXPORT( void, __msg_GenericVa, ( vlc_object_t *, int, int, const char *, const char *, va_list args ) );
114 #define msg_GenericVa(a, b, c, d, e),f __msg_GenericVa(VLC_OBJECT(a), b, c, d, e,f)
115 VLC_EXPORT( void, __msg_Info, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
116 VLC_EXPORT( void, __msg_Err, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
117 VLC_EXPORT( void, __msg_Warn, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
118 VLC_EXPORT( void, __msg_Dbg, ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
120 #ifdef HAVE_VARIADIC_MACROS
122 # define msg_Info( p_this, psz_format, args... ) \
123 __msg_Generic( VLC_OBJECT(p_this), MSG_QUEUE_NORMAL,VLC_MSG_INFO, MODULE_STRING, \
124 psz_format, ## args )
126 # define msg_Err( p_this, psz_format, args... ) \
127 __msg_Generic( VLC_OBJECT(p_this), MSG_QUEUE_NORMAL, VLC_MSG_ERR, MODULE_STRING, \
128 psz_format, ## args )
130 # define msg_Warn( p_this, psz_format, args... ) \
131 __msg_Generic( VLC_OBJECT(p_this), MSG_QUEUE_NORMAL, VLC_MSG_WARN, MODULE_STRING, \
132 psz_format, ## args )
134 # define msg_Dbg( p_this, psz_format, args... ) \
135 __msg_Generic( VLC_OBJECT(p_this), MSG_QUEUE_NORMAL, VLC_MSG_DBG, MODULE_STRING, \
136 psz_format, ## args )
138 #elif defined(_MSC_VER) /* To avoid warnings and even errors with c++ files */
140 inline void msg_Info( void *p_this, const char *psz_format, ... )
143 va_start( ap, psz_format );
144 __msg_GenericVa( ( vlc_object_t *)p_this, MSG_QUEUE_NORMAL,VLC_MSG_INFO, MODULE_STRING,
148 inline void msg_Err( void *p_this, const char *psz_format, ... )
151 va_start( ap, psz_format );
152 __msg_GenericVa( ( vlc_object_t *)p_this,MSG_QUEUE_NORMAL, VLC_MSG_ERR, MODULE_STRING,
156 inline void msg_Warn( void *p_this, const char *psz_format, ... )
159 va_start( ap, psz_format );
160 __msg_GenericVa( ( vlc_object_t *)p_this, MSG_QUEUE_NORMAL, VLC_MSG_WARN, MODULE_STRING,
164 inline void msg_Dbg( void *p_this, const char *psz_format, ... )
167 va_start( ap, psz_format );
168 __msg_GenericVa( ( vlc_object_t *)p_this, MSG_QUEUE_NORMAL, VLC_MSG_DBG, MODULE_STRING,
175 # define msg_Info __msg_Info
176 # define msg_Err __msg_Err
177 # define msg_Warn __msg_Warn
178 # define msg_Dbg __msg_Dbg
180 #endif /* HAVE_VARIADIC_MACROS */
182 #define msg_Create(a) __msg_Create(VLC_OBJECT(a))
183 #define msg_Flush(a) __msg_Flush(VLC_OBJECT(a))
184 #define msg_Destroy(a) __msg_Destroy(VLC_OBJECT(a))
185 void __msg_Create ( vlc_object_t * );
186 void __msg_Flush ( vlc_object_t * );
187 void __msg_Destroy ( vlc_object_t * );
189 #define msg_Subscribe(a,b) __msg_Subscribe(VLC_OBJECT(a),b)
190 #define msg_Unsubscribe(a,b) __msg_Unsubscribe(VLC_OBJECT(a),b)
191 VLC_EXPORT( msg_subscription_t*, __msg_Subscribe, ( vlc_object_t *, int ) );
192 VLC_EXPORT( void, __msg_Unsubscribe, ( vlc_object_t *, msg_subscription_t * ) );
200 * \defgroup statistics Statistics
213 struct counter_sample_t
226 counter_sample_t ** pp_samples;
229 struct stats_handler_t
234 counter_t **pp_counters;
237 #define stats_Update( a,b,c) __stats_Update( VLC_OBJECT( a ), b, c )
238 VLC_EXPORT( int, __stats_Update, (vlc_object_t*, char *, vlc_value_t) );
239 #define stats_Create( a,b,c,d ) __stats_Create( VLC_OBJECT(a), b, c, d )
240 VLC_EXPORT( int, __stats_Create, (vlc_object_t*, char *, int, int) );
242 static inline int __stats_UpdateInteger( vlc_object_t *p_obj, char *psz_name,
247 return __stats_Update( p_obj, psz_name, val );
249 #define stats_UpdateInteger( a,b,c ) __stats_UpdateInteger( VLC_OBJECT(a),b,c )