~ubuntu-branches/ubuntu/gutsy/audacity/gutsy-backports

« back to all changes in this revision

Viewing changes to lib-src/portaudio-v19/src/common/pa_debugprint.h

  • Committer: Bazaar Package Importer
  • Author(s): John Dong
  • Date: 2008-02-18 21:58:19 UTC
  • mfrom: (13.1.2 hardy)
  • Revision ID: james.westby@ubuntu.com-20080218215819-tmbcf1rx238r8gdv
Tags: 1.3.4-1.1ubuntu1~gutsy1
Automated backport upload; no source changes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#ifndef PA_LOG_H
2
 
#define PA_LOG_H
3
 
/*
4
 
 * Log file redirector function
5
 
 * Copyright (c) 1999-2006 Ross Bencina, Phil Burk
6
 
 *
7
 
 * Permission is hereby granted, free of charge, to any person obtaining
8
 
 * a copy of this software and associated documentation files
9
 
 * (the "Software"), to deal in the Software without restriction,
10
 
 * including without limitation the rights to use, copy, modify, merge,
11
 
 * publish, distribute, sublicense, and/or sell copies of the Software,
12
 
 * and to permit persons to whom the Software is furnished to do so,
13
 
 * subject to the following conditions:
14
 
 *
15
 
 * The above copyright notice and this permission notice shall be
16
 
 * included in all copies or substantial portions of the Software.
17
 
 *
18
 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
 
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
 
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21
 
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
22
 
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
23
 
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
 
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
 
 */
26
 
 
27
 
/*
28
 
 * The text above constitutes the entire PortAudio license; however,
29
 
 * the PortAudio community also makes the following non-binding requests:
30
 
 *
31
 
 * Any person wishing to distribute modifications to the Software is
32
 
 * requested to send the modifications to the original developer so that
33
 
 * they can be incorporated into the canonical version. It is also
34
 
 * requested that these non-binding requests be included along with the
35
 
 * license above.
36
 
 */
37
 
 
38
 
/** @file
39
 
 @ingroup common_src
40
 
*/
41
 
 
42
 
 
43
 
#ifdef __cplusplus
44
 
extern "C"
45
 
{
46
 
#endif /* __cplusplus */
47
 
 
48
 
 
49
 
 
50
 
void PaUtil_DebugPrint( const char *format, ... );
51
 
 
52
 
 
53
 
/*
54
 
    The basic format for log messages is described below. If you need to
55
 
    add any log messages, please follow this format.
56
 
 
57
 
    Function entry (void function):
58
 
 
59
 
        "FunctionName called.\n"
60
 
 
61
 
    Function entry (non void function):
62
 
 
63
 
        "FunctionName called:\n"
64
 
        "\tParam1Type param1: param1Value\n"
65
 
        "\tParam2Type param2: param2Value\n"      (etc...)
66
 
 
67
 
 
68
 
    Function exit (no return value):
69
 
 
70
 
        "FunctionName returned.\n"
71
 
 
72
 
    Function exit (simple return value):
73
 
 
74
 
        "FunctionName returned:\n"
75
 
        "\tReturnType: returnValue\n\n"
76
 
 
77
 
    If the return type is an error code, the error text is displayed in ()
78
 
 
79
 
    If the return type is not an error code, but has taken a special value
80
 
    because an error occurred, then the reason for the error is shown in []
81
 
 
82
 
    If the return type is a struct ptr, the struct is dumped.
83
 
 
84
 
    See the code below for examples
85
 
*/
86
 
 
87
 
/** PA_DEBUG() provides a simple debug message printing facility. The macro
88
 
 passes it's argument to a printf-like function called PaUtil_DebugPrint()
89
 
 which prints to stderr and always flushes the stream after printing.
90
 
 Because preprocessor macros cannot directly accept variable length argument
91
 
 lists, calls to the macro must include an additional set of parenthesis, eg:
92
 
 PA_DEBUG(("errorno: %d", 1001 ));
93
 
*/
94
 
 
95
 
 
96
 
#ifdef PA_ENABLE_DEBUG_OUTPUT
97
 
#define PA_DEBUG(x) PaUtil_DebugPrint x ;
98
 
#else
99
 
#define PA_DEBUG(x)
100
 
#endif
101
 
 
102
 
 
103
 
#ifdef PA_LOG_API_CALLS
104
 
#define PA_LOGAPI(x) PaUtil_DebugPrint x ;
105
 
#else
106
 
#define PA_LOGAPI(x)
107
 
#endif
108
 
 
109
 
    
110
 
typedef void (*PaUtilLogCallback ) (const char *log);
111
 
 
112
 
/**
113
 
    Install user provided log function
114
 
*/
115
 
void PaUtil_SetDebugPrintFunction(PaUtilLogCallback  cb);
116
 
 
117
 
 
118
 
 
119
 
#ifdef __cplusplus
120
 
}
121
 
#endif /* __cplusplus */
122
 
#endif /* PA_LOG_H */
 
1
#ifndef PA_LOG_H
 
2
 
 
3
#define PA_LOG_H
 
4
 
 
5
/*
 
6
 
 
7
 * Log file redirector function
 
8
 
 
9
 * Copyright (c) 1999-2006 Ross Bencina, Phil Burk
 
10
 
 
11
 *
 
12
 
 
13
 * Permission is hereby granted, free of charge, to any person obtaining
 
14
 
 
15
 * a copy of this software and associated documentation files
 
16
 
 
17
 * (the "Software"), to deal in the Software without restriction,
 
18
 
 
19
 * including without limitation the rights to use, copy, modify, merge,
 
20
 
 
21
 * publish, distribute, sublicense, and/or sell copies of the Software,
 
22
 
 
23
 * and to permit persons to whom the Software is furnished to do so,
 
24
 
 
25
 * subject to the following conditions:
 
26
 
 
27
 *
 
28
 
 
29
 * The above copyright notice and this permission notice shall be
 
30
 
 
31
 * included in all copies or substantial portions of the Software.
 
32
 
 
33
 *
 
34
 
 
35
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 
36
 
 
37
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
38
 
 
39
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
 
40
 
 
41
 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
 
42
 
 
43
 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
 
44
 
 
45
 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 
46
 
 
47
 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
48
 
 
49
 */
 
50
 
 
51
 
 
52
 
 
53
/*
 
54
 
 
55
 * The text above constitutes the entire PortAudio license; however,
 
56
 
 
57
 * the PortAudio community also makes the following non-binding requests:
 
58
 
 
59
 *
 
60
 
 
61
 * Any person wishing to distribute modifications to the Software is
 
62
 
 
63
 * requested to send the modifications to the original developer so that
 
64
 
 
65
 * they can be incorporated into the canonical version. It is also
 
66
 
 
67
 * requested that these non-binding requests be included along with the
 
68
 
 
69
 * license above.
 
70
 
 
71
 */
 
72
 
 
73
 
 
74
 
 
75
/** @file
 
76
 
 
77
 @ingroup common_src
 
78
 
 
79
*/
 
80
 
 
81
 
 
82
 
 
83
 
 
84
 
 
85
#ifdef __cplusplus
 
86
 
 
87
extern "C"
 
88
 
 
89
{
 
90
 
 
91
#endif /* __cplusplus */
 
92
 
 
93
 
 
94
 
 
95
 
 
96
 
 
97
 
 
98
 
 
99
void PaUtil_DebugPrint( const char *format, ... );
 
100
 
 
101
 
 
102
 
 
103
 
 
104
 
 
105
/*
 
106
 
 
107
    The basic format for log messages is described below. If you need to
 
108
 
 
109
    add any log messages, please follow this format.
 
110
 
 
111
 
 
112
 
 
113
    Function entry (void function):
 
114
 
 
115
 
 
116
 
 
117
        "FunctionName called.\n"
 
118
 
 
119
 
 
120
 
 
121
    Function entry (non void function):
 
122
 
 
123
 
 
124
 
 
125
        "FunctionName called:\n"
 
126
 
 
127
        "\tParam1Type param1: param1Value\n"
 
128
 
 
129
        "\tParam2Type param2: param2Value\n"      (etc...)
 
130
 
 
131
 
 
132
 
 
133
 
 
134
 
 
135
    Function exit (no return value):
 
136
 
 
137
 
 
138
 
 
139
        "FunctionName returned.\n"
 
140
 
 
141
 
 
142
 
 
143
    Function exit (simple return value):
 
144
 
 
145
 
 
146
 
 
147
        "FunctionName returned:\n"
 
148
 
 
149
        "\tReturnType: returnValue\n"
 
150
 
 
151
 
 
152
 
 
153
    If the return type is an error code, the error text is displayed in ()
 
154
 
 
155
 
 
156
 
 
157
    If the return type is not an error code, but has taken a special value
 
158
 
 
159
    because an error occurred, then the reason for the error is shown in []
 
160
 
 
161
 
 
162
 
 
163
    If the return type is a struct ptr, the struct is dumped.
 
164
 
 
165
 
 
166
 
 
167
    See the code below for examples
 
168
 
 
169
*/
 
170
 
 
171
 
 
172
 
 
173
/** PA_DEBUG() provides a simple debug message printing facility. The macro
 
174
 
 
175
 passes it's argument to a printf-like function called PaUtil_DebugPrint()
 
176
 
 
177
 which prints to stderr and always flushes the stream after printing.
 
178
 
 
179
 Because preprocessor macros cannot directly accept variable length argument
 
180
 
 
181
 lists, calls to the macro must include an additional set of parenthesis, eg:
 
182
 
 
183
 PA_DEBUG(("errorno: %d", 1001 ));
 
184
 
 
185
*/
 
186
 
 
187
 
 
188
 
 
189
 
 
190
 
 
191
#ifdef PA_ENABLE_DEBUG_OUTPUT
 
192
 
 
193
#define PA_DEBUG(x) PaUtil_DebugPrint x ;
 
194
 
 
195
#else
 
196
 
 
197
#define PA_DEBUG(x)
 
198
 
 
199
#endif
 
200
 
 
201
 
 
202
 
 
203
 
 
204
 
 
205
#ifdef PA_LOG_API_CALLS
 
206
 
 
207
#define PA_LOGAPI(x) PaUtil_DebugPrint x 
 
208
 
 
209
 
 
210
 
 
211
#define PA_LOGAPI_ENTER(functionName) PaUtil_DebugPrint( functionName " called.\n" )
 
212
 
 
213
 
 
214
 
 
215
#define PA_LOGAPI_ENTER_PARAMS(functionName) PaUtil_DebugPrint( functionName " called:\n" )
 
216
 
 
217
 
 
218
 
 
219
#define PA_LOGAPI_EXIT(functionName) PaUtil_DebugPrint( functionName " returned.\n" )
 
220
 
 
221
 
 
222
 
 
223
#define PA_LOGAPI_EXIT_PAERROR( functionName, result ) \
 
224
 
 
225
        PaUtil_DebugPrint( functionName " returned:\n" ); \
 
226
 
 
227
        PaUtil_DebugPrint("\tPaError: %d ( %s )\n", result, Pa_GetErrorText( result ) )
 
228
 
 
229
 
 
230
 
 
231
#define PA_LOGAPI_EXIT_T( functionName, resultFormatString, result ) \
 
232
 
 
233
        PaUtil_DebugPrint( functionName " returned:\n" ); \
 
234
 
 
235
        PaUtil_DebugPrint("\t" resultFormatString "\n", result )
 
236
 
 
237
 
 
238
 
 
239
#define PA_LOGAPI_EXIT_PAERROR_OR_T_RESULT( functionName, positiveResultFormatString, result ) \
 
240
 
 
241
        PaUtil_DebugPrint( functionName " returned:\n" ); \
 
242
 
 
243
        if( result > 0 ) \
 
244
 
 
245
        PaUtil_DebugPrint("\t" positiveResultFormatString "\n", result ); \
 
246
 
 
247
    else \
 
248
 
 
249
        PaUtil_DebugPrint("\tPaError: %d ( %s )\n", result, Pa_GetErrorText( result ) )
 
250
 
 
251
#else
 
252
 
 
253
#define PA_LOGAPI(x)
 
254
 
 
255
#define PA_LOGAPI_ENTER(functionName)
 
256
 
 
257
#define PA_LOGAPI_ENTER_PARAMS(functionName)
 
258
 
 
259
#define PA_LOGAPI_EXIT(functionName)
 
260
 
 
261
#define PA_LOGAPI_EXIT_PAERROR( functionName, result )
 
262
 
 
263
#define PA_LOGAPI_EXIT_T( functionName, resultFormatString, result )
 
264
 
 
265
#define PA_LOGAPI_EXIT_PAERROR_OR_T_RESULT( functionName, positiveResultFormatString, result )
 
266
 
 
267
#endif
 
268
 
 
269
 
 
270
 
 
271
    
 
272
 
 
273
typedef void (*PaUtilLogCallback ) (const char *log);
 
274
 
 
275
 
 
276
 
 
277
/**
 
278
 
 
279
    Install user provided log function
 
280
 
 
281
*/
 
282
 
 
283
void PaUtil_SetDebugPrintFunction(PaUtilLogCallback  cb);
 
284
 
 
285
 
 
286
 
 
287
 
 
288
 
 
289
 
 
290
 
 
291
#ifdef __cplusplus
 
292
 
 
293
}
 
294
 
 
295
#endif /* __cplusplus */
 
296
 
 
297
#endif /* PA_LOG_H */
 
298