Debian Codegraph @

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

raw symbols SCIP
1 #ifndef PA_HOSTAPI_H
2 #define PA_HOSTAPI_H
3 /*
4 * $Id: pa_hostapi.h,v 1.1 2006/06/10 21:30:55 dmazzoni Exp $
5 * Portable Audio I/O Library
6 * host api representation
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 Interface used by pa_front to virtualize functions which operate on
37 host APIs.
38 */
39
40
41 #include "portaudio.h"
42
43 #ifdef __cplusplus
44 extern "C"
45 {
46 #endif /* __cplusplus */
47
48
49 /** **FOR THE USE OF pa_front.c ONLY**
50 Do NOT use fields in this structure, they my change at any time.
51 Use functions defined in pa_util.h if you think you need functionality
52 which can be derived from here.
53 */
54 typedef struct PaUtilPrivatePaFrontHostApiInfo {
55
56
57 unsigned long baseDeviceIndex;
58 }PaUtilPrivatePaFrontHostApiInfo;
59
60
61 /** The common header for all data structures whose pointers are passed through
62 the hostApiSpecificStreamInfo field of the PaStreamParameters structure.
63 Note that in order to keep the public PortAudio interface clean, this structure
64 is not used explicitly when declaring hostApiSpecificStreamInfo data structures.
65 However, some code in pa_front depends on the first 3 members being equivalent
66 with this structure.
67 @see PaStreamParameters
68 */
69 typedef struct PaUtilHostApiSpecificStreamInfoHeader
70 {
71 unsigned long size; /**< size of whole structure including this header */
72 PaHostApiTypeId hostApiType; /**< host API for which this data is intended */
73 unsigned long version; /**< structure version */
74 } PaUtilHostApiSpecificStreamInfoHeader;
75
76
77
78 /** A structure representing the interface to a host API. Contains both
79 concrete data and pointers to functions which implement the interface.
80 */
81 typedef struct PaUtilHostApiRepresentation {
82 PaUtilPrivatePaFrontHostApiInfo privatePaFrontInfo;
83
84 /** The host api implementation should populate the info field. In the
85 case of info.defaultInputDevice and info.defaultOutputDevice the
86 values stored should be 0 based indices within the host api's own
87 device index range (0 to deviceCount). These values will be converted
88 to global device indices by pa_front after PaUtilHostApiInitializer()
89 returns.
90 */
91 PaHostApiInfo info;
92
93 PaDeviceInfo** deviceInfos;
94
95 /**
96 (*Terminate)() is guaranteed to be called with a valid <hostApi>
97 parameter, which was previously returned from the same implementation's
98 initializer.
99 */
100 void (*Terminate)( struct PaUtilHostApiRepresentation *hostApi );
101
102 /**
103 The inputParameters and outputParameters pointers should not be saved
104 as they will not remain valid after OpenStream is called.
105
106
107 The following guarantees are made about parameters to (*OpenStream)():
108
109 [NOTE: the following list up to *END PA FRONT VALIDATIONS* should be
110 kept in sync with the one for ValidateOpenStreamParameters and
111 Pa_OpenStream in pa_front.c]
112
113 PaHostApiRepresentation *hostApi
114 - is valid for this implementation
115
116 PaStream** stream
117 - is non-null
118
119 - at least one of inputParameters & outputParmeters is valid (not NULL)
120
121 - if inputParameters & outputParmeters are both valid, that
122 inputParameters->device & outputParmeters->device both use the same host api
123
124 PaDeviceIndex inputParameters->device
125 - is within range (0 to Pa_CountDevices-1) Or:
126 - is paUseHostApiSpecificDeviceSpecification and
127 inputParameters->hostApiSpecificStreamInfo is non-NULL and refers
128 to a valid host api
129
130 int inputParameters->numChannels
131 - if inputParameters->device is not paUseHostApiSpecificDeviceSpecification, numInputChannels is > 0
132 - upper bound is NOT validated against device capabilities
133
134 PaSampleFormat inputParameters->sampleFormat
135 - is one of the sample formats defined in portaudio.h
136
137 void *inputParameters->hostApiSpecificStreamInfo
138 - if supplied its hostApi field matches the input device's host Api
139
140 PaDeviceIndex outputParmeters->device
141 - is within range (0 to Pa_CountDevices-1)
142
143 int outputParmeters->numChannels
144 - if inputDevice is valid, numInputChannels is > 0
145 - upper bound is NOT validated against device capabilities
146
147 PaSampleFormat outputParmeters->sampleFormat
148 - is one of the sample formats defined in portaudio.h
149
150 void *outputParmeters->hostApiSpecificStreamInfo
151 - if supplied its hostApi field matches the output device's host Api
152
153 double sampleRate
154 - is not an 'absurd' rate (less than 1000. or greater than 200000.)
155 - sampleRate is NOT validated against device capabilities
156
157 PaStreamFlags streamFlags
158 - unused platform neutral flags are zero
159 - paNeverDropInput is only used for full-duplex callback streams
160 with variable buffer size (paFramesPerBufferUnspecified)
161
162 [*END PA FRONT VALIDATIONS*]
163
164
165 The following validations MUST be performed by (*OpenStream)():
166
167 - check that input device can support numInputChannels
168
169 - check that input device can support inputSampleFormat, or that
170 we have the capability to convert from outputSampleFormat to
171 a native format
172
173 - if inputStreamInfo is supplied, validate its contents,
174 or return an error if no inputStreamInfo is expected
175
176 - check that output device can support numOutputChannels
177
178 - check that output device can support outputSampleFormat, or that
179 we have the capability to convert from outputSampleFormat to
180 a native format
181
182 - if outputStreamInfo is supplied, validate its contents,
183 or return an error if no outputStreamInfo is expected
184
185 - if a full duplex stream is requested, check that the combination
186 of input and output parameters is supported
187
188 - check that the device supports sampleRate
189
190 - alter sampleRate to a close allowable rate if necessary
191
192 - validate inputLatency and outputLatency
193
194 - validate any platform specific flags, if flags are supplied they
195 must be valid.
196 */
197 PaError (*OpenStream)( struct PaUtilHostApiRepresentation *hostApi,
198 PaStream** stream,
199 const PaStreamParameters *inputParameters,
200 const PaStreamParameters *outputParameters,
201 double sampleRate,
202 unsigned long framesPerCallback,
203 PaStreamFlags streamFlags,
204 PaStreamCallback *streamCallback,
205 void *userData );
206
207
208 PaError (*IsFormatSupported)( struct PaUtilHostApiRepresentation *hostApi,
209 const PaStreamParameters *inputParameters,
210 const PaStreamParameters *outputParameters,
211 double sampleRate );
212 } PaUtilHostApiRepresentation;
213
214
215 /** Prototype for the initialization function which must be implemented by every
216 host API.
217
218 @see paHostApiInitializers
219 */
220 typedef PaError PaUtilHostApiInitializer( PaUtilHostApiRepresentation**, PaHostApiIndex );
221
222
223 /** paHostApiInitializers is a NULL-terminated array of host API initialization
224 functions. These functions are called by pa_front to initialize the host APIs
225 when the client calls Pa_Initialize().
226
227 There is a platform specific file which defines paHostApiInitializers for that
228 platform, pa_win/pa_win_hostapis.c contains the Win32 definitions for example.
229 */
230 extern PaUtilHostApiInitializer *paHostApiInitializers[];
231
232
233 /** The index of the default host API in the paHostApiInitializers array.
234
235 There is a platform specific file which defines paDefaultHostApiIndex for that
236 platform, see pa_win/pa_win_hostapis.c for example.
237 */
238 extern int paDefaultHostApiIndex;
239
240
241 #ifdef __cplusplus
242 }
243 #endif /* __cplusplus */
244 #endif /* PA_HOSTAPI_H */