]> git.sesse.net Git - vlc/blob - include/vlc_messages.h
all:
[vlc] / include / vlc_messages.h
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 VideoLAN
7  * $Id: vlc_messages.h,v 1.9 2003/12/03 23:01:48 sigmunau Exp $
8  *
9  * Authors: Vincent Seguin <seguin@via.ecp.fr>
10  *          Samuel Hocevar <sam@zoy.org>
11  *
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.
16  *
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.
21  *
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  *****************************************************************************/
26
27 #include <stdarg.h>
28 /**
29  * \defgroup messages Messages
30  * This library provides basic functions for threads to interact with user
31  * interface, such as message output.
32  *
33  * @{
34  */
35
36
37 /**
38  * Store a single message.
39  */
40 typedef struct
41 {
42     int     i_type;                             /**< message type, see below */
43     int     i_object_id;
44     int     i_object_type;
45     char *  psz_module;
46     char *  psz_msg;                                 /**< the message itself */
47
48 #if 0
49     mtime_t date;                                     /* date of the message */
50     char *  psz_file;               /* file in which the function was called */
51     char *  psz_function;     /* function from which the function was called */
52     int     i_line;                 /* line at which the function was called */
53 #endif
54 } msg_item_t;
55
56 /* Message types */
57 /** standard messages */
58 #define VLC_MSG_INFO  0                               
59 /** error messages */
60 #define VLC_MSG_ERR   1                                  
61 /** warning messages */
62 #define VLC_MSG_WARN  2
63 /** debug messages */
64 #define VLC_MSG_DBG   3
65
66 /**
67  * Store all data requiered by messages interfaces.
68  */
69 struct msg_bank_t
70 {
71     /** Message queue lock */
72     vlc_mutex_t             lock;
73     vlc_bool_t              b_configured;
74     vlc_bool_t              b_overflow;
75
76     /* Message queue */
77     msg_item_t              msg[VLC_MSG_QSIZE];           /**< message queue */
78     int i_start;
79     int i_stop;
80
81     /* Subscribers */
82     int i_sub;
83     msg_subscription_t **pp_sub;
84
85     /* Logfile for WinCE */
86 #ifdef UNDER_CE
87     FILE *logfile;
88 #endif
89 };
90
91 /**
92  * Used by interface plugins which subscribe to the message bank.
93  */
94 struct msg_subscription_t
95 {
96     int   i_start;
97     int*  pi_stop;
98
99     msg_item_t*  p_msg;
100     vlc_mutex_t* p_lock;
101 };
102
103 /*****************************************************************************
104  * Prototypes
105  *****************************************************************************/
106 VLC_EXPORT( void, __msg_Generic, ( vlc_object_t *, int, const char *, const char *, ... ) ATTRIBUTE_FORMAT( 4, 5 ) );
107 VLC_EXPORT( void, __msg_Info,    ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
108 VLC_EXPORT( void, __msg_Err,     ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
109 VLC_EXPORT( void, __msg_Warn,    ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
110 VLC_EXPORT( void, __msg_Dbg,    ( vlc_object_t *, const char *, ... ) ATTRIBUTE_FORMAT( 2, 3 ) );
111
112 #ifdef HAVE_VARIADIC_MACROS
113
114 #   define msg_Info( p_this, psz_format, args... ) \
115       __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_INFO, MODULE_STRING, \
116                      psz_format, ## args )
117
118 #   define msg_Err( p_this, psz_format, args... ) \
119       __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_ERR, MODULE_STRING, \
120                      psz_format, ## args )
121
122 #   define msg_Warn( p_this, psz_format, args... ) \
123       __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_WARN, MODULE_STRING, \
124                      psz_format, ## args )
125
126 #   define msg_Dbg( p_this, psz_format, args... ) \
127       __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_DBG, MODULE_STRING, \
128                      psz_format, ## args )
129
130 #else /* HAVE_VARIADIC_MACROS */
131
132 #   define msg_Info __msg_Info
133 #   define msg_Err __msg_Err
134 #   define msg_Warn __msg_Warn
135 #   define msg_Dbg __msg_Dbg
136
137 #endif /* HAVE_VARIADIC_MACROS */
138
139 #define msg_Create(a) __msg_Create(VLC_OBJECT(a))
140 #define msg_Flush(a) __msg_Flush(VLC_OBJECT(a))
141 #define msg_Destroy(a) __msg_Destroy(VLC_OBJECT(a))
142 void __msg_Create  ( vlc_object_t * );
143 void __msg_Flush   ( vlc_object_t * );
144 void __msg_Destroy ( vlc_object_t * );
145
146 #define msg_Subscribe(a) __msg_Subscribe(VLC_OBJECT(a))
147 #define msg_Unsubscribe(a,b) __msg_Unsubscribe(VLC_OBJECT(a),b)
148 VLC_EXPORT( msg_subscription_t*, __msg_Subscribe, ( vlc_object_t * ) );
149 VLC_EXPORT( void, __msg_Unsubscribe, ( vlc_object_t *, msg_subscription_t * ) );
150
151
152 /**
153  * @}
154  */