]> git.sesse.net Git - vlc/blob - include/vlc_messages.h
* ./msvc/*, ./evc/*: moved eMbedded Visual Studio files to the toplevel evc/
[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.7 2002/11/13 15:28:24 sam 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 /*****************************************************************************
30  * msg_item_t
31  *****************************************************************************
32  * Store a single message.
33  *****************************************************************************/
34 typedef struct
35 {
36     int     i_type;                               /* message type, see below */
37     int     i_object_id;
38     int     i_object_type;
39     char *  psz_module;
40     char *  psz_msg;                                   /* the message itself */
41
42 #if 0
43     mtime_t date;                                     /* date of the message */
44     char *  psz_file;               /* file in which the function was called */
45     char *  psz_function;     /* function from which the function was called */
46     int     i_line;                 /* line at which the function was called */
47 #endif
48 } msg_item_t;
49
50 /* Message types */
51 #define VLC_MSG_INFO  0                                 /* standard messages */
52 #define VLC_MSG_ERR   1                                    /* error messages */
53 #define VLC_MSG_WARN  2                                  /* warning messages */
54 #define VLC_MSG_DBG   3                                    /* debug messages */
55
56 /*****************************************************************************
57  * msg_bank_t
58  *****************************************************************************
59  * Store all data requiered by messages interfaces.
60  *****************************************************************************/
61 struct msg_bank_t
62 {
63     /* Message queue lock */
64     vlc_mutex_t             lock;
65     vlc_bool_t              b_configured;
66     vlc_bool_t              b_overflow;
67
68     /* Message queue */
69     msg_item_t              msg[VLC_MSG_QSIZE];             /* message queue */
70     int i_start;
71     int i_stop;
72
73     /* Subscribers */
74     int i_sub;
75     msg_subscription_t **pp_sub;
76
77     /* Logfile for WinCE */
78 #ifdef UNDER_CE
79     FILE *logfile;
80 #endif
81 };
82
83 /*****************************************************************************
84  * msg_subscription_t
85  *****************************************************************************
86  * Used by interface plugins which subscribe to the message bank.
87  *****************************************************************************/
88 struct msg_subscription_t
89 {
90     int   i_start;
91     int*  pi_stop;
92
93     msg_item_t*  p_msg;
94     vlc_mutex_t* p_lock;
95 };
96
97 /*****************************************************************************
98  * Prototypes
99  *****************************************************************************/
100 VLC_EXPORT( void, __msg_Generic, ( vlc_object_t *, int, const char *, const char *, ... ) );
101 VLC_EXPORT( void, __msg_Info,    ( void *, const char *, ... ) );
102 VLC_EXPORT( void, __msg_Err,     ( void *, const char *, ... ) );
103 VLC_EXPORT( void, __msg_Warn,    ( void *, const char *, ... ) );
104 VLC_EXPORT( void, __msg_Dbg,    ( void *, const char *, ... ) );
105
106 #ifdef HAVE_VARIADIC_MACROS
107
108 #   define msg_Info( p_this, psz_format, args... ) \
109       __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_INFO, MODULE_STRING, \
110                      psz_format, ## args )
111
112 #   define msg_Err( p_this, psz_format, args... ) \
113       __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_ERR, MODULE_STRING, \
114                      psz_format, ## args )
115
116 #   define msg_Warn( p_this, psz_format, args... ) \
117       __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_WARN, MODULE_STRING, \
118                      psz_format, ## args )
119
120 #   define msg_Dbg( p_this, psz_format, args... ) \
121       __msg_Generic( VLC_OBJECT(p_this), VLC_MSG_DBG, MODULE_STRING, \
122                      psz_format, ## args )
123
124 #else /* HAVE_VARIADIC_MACROS */
125
126 #   define msg_Info __msg_Info
127 #   define msg_Err __msg_Err
128 #   define msg_Warn __msg_Warn
129 #   define msg_Dbg __msg_Dbg
130
131 #endif /* HAVE_VARIADIC_MACROS */
132
133 #define msg_Create(a) __msg_Create(VLC_OBJECT(a))
134 #define msg_Flush(a) __msg_Flush(VLC_OBJECT(a))
135 #define msg_Destroy(a) __msg_Destroy(VLC_OBJECT(a))
136 void __msg_Create  ( vlc_object_t * );
137 void __msg_Flush   ( vlc_object_t * );
138 void __msg_Destroy ( vlc_object_t * );
139
140 #define msg_Subscribe(a) __msg_Subscribe(VLC_OBJECT(a))
141 #define msg_Unsubscribe(a,b) __msg_Unsubscribe(VLC_OBJECT(a),b)
142 VLC_EXPORT( msg_subscription_t*, __msg_Subscribe, ( vlc_object_t * ) );
143 VLC_EXPORT( void, __msg_Unsubscribe, ( vlc_object_t *, msg_subscription_t * ) );
144