Debian Codegraph @

3rdparty/iaxclient/lib/portaudio/src/common/pa_util.h

raw symbols SCIP
1 #ifndef PA_UTIL_H
2 #define PA_UTIL_H
3 /*
4 * $Id: pa_util.h,v 1.1 2006/06/10 21:30:55 dmazzoni Exp $
5 * Portable Audio I/O Library implementation utilities header
6 * common implementation utilities and interfaces
7 *
8 * Based on the Open Source API proposed by Ross Bencina
9 * Copyright (c) 1999-2002 Ross Bencina, Phil Burk
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining
12 * a copy of this software and associated documentation files
13 * (the "Software"), to deal in the Software without restriction,
14 * including without limitation the rights to use, copy, modify, merge,
15 * publish, distribute, sublicense, and/or sell copies of the Software,
16 * and to permit persons to whom the Software is furnished to do so,
17 * subject to the following conditions:
18 *
19 * The above copyright notice and this permission notice shall be
20 * included in all copies or substantial portions of the Software.
21 *
22 * Any person wishing to distribute modifications to the Software is
23 * requested to send the modifications to the original developer so that
24 * they can be incorporated into the canonical version.
25 *
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
29 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
30 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
31 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
32 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 */
34
35 /** @file
36 @brief Prototypes for utility functions used by PortAudio implementations.
37
38 @todo Document and adhere to the alignment guarantees provided by
39 PaUtil_AllocateMemory().
40 */
41
42
43 #include "portaudio.h"
44
45 #ifdef __cplusplus
46 extern "C"
47 {
48 #endif /* __cplusplus */
49
50
51 struct PaUtilHostApiRepresentation;
52
53
54 /** Retrieve a specific host API representation. This function can be used
55 by implementations to retrieve a pointer to their representation in
56 host api specific extension functions which aren't passed a rep pointer
57 by pa_front.c.
58
59 @param hostApi A pointer to a host API represenation pointer. Apon success
60 this will receive the requested representation pointer.
61
62 @param type A valid host API type identifier.
63
64 @returns An error code. If the result is PaNoError then a pointer to the
65 requested host API representation will be stored in *hostApi. If the host API
66 specified by type is not found, this function returns paHostApiNotFound.
67 */
68 PaError PaUtil_GetHostApiRepresentation( struct PaUtilHostApiRepresentation **hostApi,
69 PaHostApiTypeId type );
70
71
72 /** Convert a PortAudio device index into a host API specific device index.
73 @param hostApiDevice Pointer to a device index, on success this will recieve the
74 converted device index value.
75 @param device The PortAudio device index to convert.
76 @param hostApi The host api which the index should be converted for.
77
78 @returns On success returns PaNoError and places the converted index in the
79 hostApiDevice parameter.
80 */
81 PaError PaUtil_DeviceIndexToHostApiDeviceIndex(
82 PaDeviceIndex *hostApiDevice, PaDeviceIndex device,
83 struct PaUtilHostApiRepresentation *hostApi );
84
85
86 /** Set the host error information returned by Pa_GetLastHostErrorInfo. This
87 function and the paUnanticipatedHostError error code should be used as a
88 last resort. Implementors should use existing PA error codes where possible,
89 or nominate new ones. Note that at it is always better to use
90 PaUtil_SetLastHostErrorInfo() and paUnanticipatedHostError than to return an
91 ambiguous or inaccurate PaError code.
92
93 @param hostApiType The host API which encountered the error (ie of the caller)
94
95 @param errorCode The error code returned by the native API function.
96
97 @param errorText A string describing the error. PaUtil_SetLastHostErrorInfo
98 makes a copy of the string, so it is not necessary for the pointer to remain
99 valid after the call to PaUtil_SetLastHostErrorInfo() returns.
100
101 */
102 void PaUtil_SetLastHostErrorInfo( PaHostApiTypeId hostApiType, long errorCode,
103 const char *errorText );
104
105
106
107 /** PA_DEBUG() provides a simple debug message printing facility. The macro
108 passes it's argument to a printf-like function called PaUtil_DebugPrint()
109 which prints to stderr and always flushes the stream after printing.
110 Because preprocessor macros cannot directly accept variable length argument
111 lists, calls to the macro must include an additional set of parenthesis, eg:
112 PA_DEBUG(("errorno: %d", 1001 ));
113 */
114
115 void PaUtil_DebugPrint( const char *format, ... );
116
117 #ifdef PA_ENABLE_DEBUG_OUTPUT
118 #define PA_DEBUG(x) PaUtil_DebugPrint x ;
119 #else
120 #define PA_DEBUG(x)
121 #endif
122
123
124 /* the following functions are implemented in a platform platform specific
125 .c file
126 */
127
128 /** Allocate size bytes, guaranteed to be aligned to a FIXME byte boundary */
129 void *PaUtil_AllocateMemory( long size );
130
131
132 /** Realease block if non-NULL. block may be NULL */
133 void PaUtil_FreeMemory( void *block );
134
135
136 /** Return the number of currently allocated blocks. This function can be
137 used for detecting memory leaks.
138
139 @note Allocations will only be tracked if PA_TRACK_MEMORY is #defined. If
140 it isn't, this function will always return 0.
141 */
142 int PaUtil_CountCurrentlyAllocatedBlocks( void );
143
144
145 /** Initialize the clock used by PaUtil_GetTime(). Call this before calling
146 PaUtil_GetTime.
147
148 @see PaUtil_GetTime
149 */
150 void PaUtil_InitializeClock( void );
151
152
153 /** Return the system time in seconds. Used to implement CPU load functions
154
155 @see PaUtil_InitializeClock
156 */
157 double PaUtil_GetTime( void );
158
159
160 /* void Pa_Sleep( long msec ); must also be implemented in per-platform .c file */
161
162
163
164 #ifdef __cplusplus
165 }
166 #endif /* __cplusplus */
167 #endif /* PA_UTIL_H */