]> git.sesse.net Git - vlc/blob - include/vlc_messages.h
* ALL: got rid of p_object->p_this which is now useless.
[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.2 2002/06/01 18:04:48 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     char *  psz_module;
38     char *  psz_msg;                                   /* the message itself */
39
40 #if 0
41     mtime_t date;                                     /* date of the message */
42     char *  psz_file;               /* file in which the function was called */
43     char *  psz_function;     /* function from which the function was called */
44     int     i_line;                 /* line at which the function was called */
45 #endif
46 } msg_item_t;
47
48 /* Message types */
49 #define VLC_MSG_INFO  0                                 /* standard messages */
50 #define VLC_MSG_ERR   1                                    /* error messages */
51 #define VLC_MSG_WARN  2                                  /* warning messages */
52 #define VLC_MSG_DBG   3                                    /* debug messages */
53
54 /*****************************************************************************
55  * msg_bank_t
56  *****************************************************************************
57  * Store all data requiered by messages interfaces.
58  *****************************************************************************/
59 struct msg_bank_s
60 {
61     /* Message queue lock */
62     vlc_mutex_t             lock;
63
64     /* Message queue */
65     msg_item_t              msg[VLC_MSG_QSIZE];             /* message queue */
66     int i_start;
67     int i_stop;
68
69     /* Subscribers */
70     int i_sub;
71     msg_subscription_t **pp_sub;
72 };
73
74 /*****************************************************************************
75  * msg_subscription_t
76  *****************************************************************************
77  * Used by interface plugins which subscribe to the message bank.
78  *****************************************************************************/
79 struct msg_subscription_s
80 {
81     int   i_start;
82     int*  pi_stop;
83
84     msg_item_t*  p_msg;
85     vlc_mutex_t* p_lock;
86 };
87
88 /*****************************************************************************
89  * Prototypes
90  *****************************************************************************/
91 VLC_EXPORT( void, __msg_Generic, ( vlc_object_t *, int, const char *, const char *, ... ) );
92 VLC_EXPORT( void, __msg_Info,    ( void *, const char *, ... ) );
93 VLC_EXPORT( void, __msg_Err,     ( void *, const char *, ... ) );
94 VLC_EXPORT( void, __msg_Warn,    ( void *, const char *, ... ) );
95 VLC_EXPORT( void, __msg_Dbg,    ( void *, const char *, ... ) );
96
97 #ifdef HAVE_VARIADIC_MACROS
98
99 #   define msg_Info( p_this, psz_format, args... ) \
100       __msg_Generic( CAST_TO_VLC_OBJECT(p_this), VLC_MSG_INFO, MODULE_STRING, \
101                      psz_format, ## args )
102
103 #   define msg_Err( p_this, psz_format, args... ) \
104       __msg_Generic( CAST_TO_VLC_OBJECT(p_this), VLC_MSG_ERR, MODULE_STRING, \
105                      psz_format, ## args )
106
107 #   define msg_Warn( p_this, psz_format, args... ) \
108       __msg_Generic( CAST_TO_VLC_OBJECT(p_this), VLC_MSG_WARN, MODULE_STRING, \
109                      psz_format, ## args )
110
111 #   define msg_Dbg( p_this, psz_format, args... ) \
112       __msg_Generic( CAST_TO_VLC_OBJECT(p_this), VLC_MSG_DBG, MODULE_STRING, \
113                      psz_format, ## args )
114
115 #else /* HAVE_VARIADIC_MACROS */
116
117 #   define msg_Info __msg_Info
118 #   define msg_Err __msg_Err
119 #   define msg_Warn __msg_Warn
120 #   define msg_Dbg __msg_Dbg
121
122 #endif /* HAVE_VARIADIC_MACROS */
123
124 #define msg_Create(a) __msg_Create(CAST_TO_VLC_OBJECT(a))
125 #define msg_Destroy(a) __msg_Destroy(CAST_TO_VLC_OBJECT(a))
126 void __msg_Create  ( vlc_object_t * );
127 void __msg_Destroy ( vlc_object_t * );
128
129 #define msg_Subscribe(a) __msg_Subscribe(CAST_TO_VLC_OBJECT(a))
130 #define msg_Unsubscribe(a,b) __msg_Unsubscribe(CAST_TO_VLC_OBJECT(a),b)
131 VLC_EXPORT( msg_subscription_t*, __msg_Subscribe, ( vlc_object_t * ) );
132 VLC_EXPORT( void, __msg_Unsubscribe, ( vlc_object_t *, msg_subscription_t * ) );
133