Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

vlc_messages.h

00001 /*****************************************************************************
00002  * messages.h: messages interface
00003  * This library provides basic functions for threads to interact with user
00004  * interface, such as message output.
00005  *****************************************************************************
00006  * Copyright (C) 1999, 2000, 2001, 2002 the VideoLAN team
00007  * $Id: vlc_messages.h 12122 2005-08-11 13:39:43Z massiot $
00008  *
00009  * Authors: Vincent Seguin <[email protected]>
00010  *          Samuel Hocevar <[email protected]>
00011  *
00012  * This program is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00025  *****************************************************************************/
00026 
00027 #include <stdarg.h>
00040 typedef struct
00041 {
00042     int     i_type;                             
00043     int     i_object_id;
00044     int     i_object_type;
00045     char *  psz_module;
00046     char *  psz_msg;                                 
00048 #if 0
00049     mtime_t date;                                     /* date of the message */
00050     char *  psz_file;               /* file in which the function was called */
00051     char *  psz_function;     /* function from which the function was called */
00052     int     i_line;                 /* line at which the function was called */
00053 #endif
00054 } msg_item_t;
00055 
00056 /* Message types */
00058 #define VLC_MSG_INFO  0
00059 
00060 #define VLC_MSG_ERR   1
00061 
00062 #define VLC_MSG_WARN  2
00063 
00064 #define VLC_MSG_DBG   3
00065 
00069 struct msg_bank_t
00070 {
00072     vlc_mutex_t             lock;
00073     vlc_bool_t              b_configured;
00074     vlc_bool_t              b_overflow;
00075 
00076     /* Message queue */
00077     msg_item_t              msg[VLC_MSG_QSIZE];           
00078     int i_start;
00079     int i_stop;
00080 
00081     /* Subscribers */
00082     int i_sub;
00083     msg_subscription_t **pp_sub;
00084 
00085     /* Logfile for WinCE */
00086 #ifdef UNDER_CE
00087     FILE *logfile;
00088 #endif
00089 };
00090 
00094 struct msg_subscription_t
00095 {
00096     int   i_start;
00097     int*  pi_stop;
00098 
00099     msg_item_t*  p_msg;
00100     vlc_mutex_t* p_lock;
00101 };
00102 
00103 /*****************************************************************************
00104  * Prototypes
00105  *****************************************************************************/
00106 VLC_EXPORT( void, __msg_Generic, ( vlc_object_t *, int, const char *, const char *, ... ) ATTRIBUTE_FORMAT( 4, 5 ) );
00107 VLC_EXPORT( void, __msg_GenericVa, ( vlc_object_t *, int, const char *, const char *, va_list args ) );
00108 #define msg_GenericVa(a, b, c, d, e) __msg_GenericVa(VLC_OBJECT(a), b, c, d, e)
00109 VLC_EXPORT( void, __msg_Info,    ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
00110 VLC_EXPORT( void, __msg_Err,     ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
00111 VLC_EXPORT( void, __msg_Warn,    ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
00112 VLC_EXPORT( void, __msg_Dbg,    ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
00113 
00114 #ifdef HAVE_VARIADIC_MACROS
00115 
00116 #   define msg_Info( p_this, psz_format, args... ) \
00117       __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_INFO, MODULE_STRING, \
00118                      psz_format, ## args )
00119 
00120 #   define msg_Err( p_this, psz_format, args... ) \
00121       __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_ERR, MODULE_STRING, \
00122                      psz_format, ## args )
00123 
00124 #   define msg_Warn( p_this, psz_format, args... ) \
00125       __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_WARN, MODULE_STRING, \
00126                      psz_format, ## args )
00127 
00128 #   define msg_Dbg( p_this, psz_format, args... ) \
00129       __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_DBG, MODULE_STRING, \
00130                      psz_format, ## args )
00131 
00132 #elif defined(_MSC_VER) /* To avoid warnings and even errors with c++ files */
00133 
00134 inline void msg_Info( void *p_this, const char *psz_format, ... )
00135 {
00136   va_list ap;
00137   va_start( ap, psz_format );
00138   __msg_GenericVa( ( vlc_object_t *)p_this, VLC_MSG_INFO, MODULE_STRING,
00139                    psz_format, ap );
00140   va_end(ap);
00141 }
00142 inline void msg_Err( void *p_this, const char *psz_format, ... )
00143 {
00144   va_list ap;
00145   va_start( ap, psz_format );
00146   __msg_GenericVa( ( vlc_object_t *)p_this, VLC_MSG_ERR, MODULE_STRING,
00147                    psz_format, ap );
00148   va_end(ap);
00149 }
00150 inline void msg_Warn( void *p_this, const char *psz_format, ... )
00151 {
00152   va_list ap;
00153   va_start( ap, psz_format );
00154   __msg_GenericVa( ( vlc_object_t *)p_this, VLC_MSG_WARN, MODULE_STRING,
00155                    psz_format, ap );
00156   va_end(ap);
00157 }
00158 inline void msg_Dbg( void *p_this, const char *psz_format, ... )
00159 {
00160   va_list ap;
00161   va_start( ap, psz_format );
00162   __msg_GenericVa( ( vlc_object_t *)p_this, VLC_MSG_DBG, MODULE_STRING,
00163                    psz_format, ap );
00164   va_end(ap);
00165 }
00166 
00167 #else /* _MSC_VER */
00168 
00169 #   define msg_Info __msg_Info
00170 #   define msg_Err __msg_Err
00171 #   define msg_Warn __msg_Warn
00172 #   define msg_Dbg __msg_Dbg
00173 
00174 #endif /* HAVE_VARIADIC_MACROS */
00175 
00176 #define msg_Create(a) __msg_Create(VLC_OBJECT(a))
00177 #define msg_Flush(a) __msg_Flush(VLC_OBJECT(a))
00178 #define msg_Destroy(a) __msg_Destroy(VLC_OBJECT(a))
00179 void __msg_Create  ( vlc_object_t * );
00180 void __msg_Flush   ( vlc_object_t * );
00181 void __msg_Destroy ( vlc_object_t * );
00182 
00183 #define msg_Subscribe(a) __msg_Subscribe(VLC_OBJECT(a))
00184 #define msg_Unsubscribe(a,b) __msg_Unsubscribe(VLC_OBJECT(a),b)
00185 VLC_EXPORT( msg_subscription_t*, __msg_Subscribe, ( vlc_object_t * ) );
00186 VLC_EXPORT( void, __msg_Unsubscribe, ( vlc_object_t *, msg_subscription_t * ) );
00187 
00188 

Generated on Tue Dec 20 10:14:19 2005 for vlc-0.8.4a by  doxygen 1.4.2