]> git.mxchange.org Git - flightgear.git/blob - utils/iaxclient/lib/portaudio/src/common/pa_trace.c
Fix Windows warning during Windows compilation
[flightgear.git] / utils / iaxclient / lib / portaudio / src / common / pa_trace.c
1 /*
2  * $Id: pa_trace.c,v 1.1 2006/06/10 21:30:55 dmazzoni Exp $
3  * Portable Audio I/O Library Trace Facility
4  * Store trace information in real-time for later printing.
5  *
6  * Based on the Open Source API proposed by Ross Bencina
7  * Copyright (c) 1999-2000 Phil Burk
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files
11  * (the "Software"), to deal in the Software without restriction,
12  * including without limitation the rights to use, copy, modify, merge,
13  * publish, distribute, sublicense, and/or sell copies of the Software,
14  * and to permit persons to whom the Software is furnished to do so,
15  * subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * Any person wishing to distribute modifications to the Software is
21  * requested to send the modifications to the original developer so that
22  * they can be incorporated into the canonical version.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
27  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
28  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
29  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31  */
32
33 /** @file
34  @brief Event trace mechanism for debugging.
35 */
36
37
38 #include <stdio.h>
39 #include <stdlib.h>
40 #include <string.h>
41 #include "pa_trace.h"
42
43 #if PA_TRACE_REALTIME_EVENTS
44
45 static char *traceTextArray[PA_MAX_TRACE_RECORDS];
46 static int traceIntArray[PA_MAX_TRACE_RECORDS];
47 static int traceIndex = 0;
48 static int traceBlock = 0;
49
50 /*********************************************************************/
51 void PaUtil_ResetTraceMessages()
52 {
53     traceIndex = 0;
54 }
55
56 /*********************************************************************/
57 void PaUtil_DumpTraceMessages()
58 {
59     int i;
60     int messageCount = (traceIndex < PA_MAX_TRACE_RECORDS) ? traceIndex : PA_MAX_TRACE_RECORDS;
61
62     printf("DumpTraceMessages: traceIndex = %d\n", traceIndex );
63     for( i=0; i<messageCount; i++ )
64     {
65         printf("%3d: %s = 0x%08X\n",
66                i, traceTextArray[i], traceIntArray[i] );
67     }
68     PaUtil_ResetTraceMessages();
69     fflush(stdout);
70 }
71
72 /*********************************************************************/
73 void PaUtil_AddTraceMessage( const char *msg, int data )
74 {
75     if( (traceIndex == PA_MAX_TRACE_RECORDS) && (traceBlock == 0) )
76     {
77         traceBlock = 1;
78         /*  PaUtil_DumpTraceMessages(); */
79     }
80     else if( traceIndex < PA_MAX_TRACE_RECORDS )
81     {
82         traceTextArray[traceIndex] = msg;
83         traceIntArray[traceIndex] = data;
84         traceIndex++;
85     }
86 }
87
88 #endif /* TRACE_REALTIME_EVENTS */