4
* $Id: pa_hostapi.h 1339 2008-02-15 07:50:33Z rossb $
5
* Portable Audio I/O Library
6
* host api representation
8
* Based on the Open Source API proposed by Ross Bencina
9
* Copyright (c) 1999-2008 Ross Bencina, Phil Burk
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:
19
* The above copyright notice and this permission notice shall be
20
* included in all copies or substantial portions of the Software.
22
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
26
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
27
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
32
* The text above constitutes the entire PortAudio license; however,
33
* the PortAudio community also makes the following non-binding requests:
35
* Any person wishing to distribute modifications to the Software is
36
* requested to send the modifications to the original developer so that
37
* they can be incorporated into the canonical version. It is also
38
* requested that these non-binding requests be included along with the
45
@brief Interfaces and representation structures used by pa_front.c
46
to manage and communicate with host API implementations.
50
#include "portaudio.h"
55
#endif /* __cplusplus */
58
/** **FOR THE USE OF pa_front.c ONLY**
59
Do NOT use fields in this structure, they my change at any time.
60
Use functions defined in pa_util.h if you think you need functionality
61
which can be derived from here.
63
typedef struct PaUtilPrivatePaFrontHostApiInfo {
66
unsigned long baseDeviceIndex;
67
}PaUtilPrivatePaFrontHostApiInfo;
70
/** The common header for all data structures whose pointers are passed through
71
the hostApiSpecificStreamInfo field of the PaStreamParameters structure.
72
Note that in order to keep the public PortAudio interface clean, this structure
73
is not used explicitly when declaring hostApiSpecificStreamInfo data structures.
74
However, some code in pa_front depends on the first 3 members being equivalent
76
@see PaStreamParameters
78
typedef struct PaUtilHostApiSpecificStreamInfoHeader
80
unsigned long size; /**< size of whole structure including this header */
81
PaHostApiTypeId hostApiType; /**< host API for which this data is intended */
82
unsigned long version; /**< structure version */
83
} PaUtilHostApiSpecificStreamInfoHeader;
87
/** A structure representing the interface to a host API. Contains both
88
concrete data and pointers to functions which implement the interface.
90
typedef struct PaUtilHostApiRepresentation {
91
PaUtilPrivatePaFrontHostApiInfo privatePaFrontInfo;
93
/** The host api implementation should populate the info field. In the
94
case of info.defaultInputDevice and info.defaultOutputDevice the
95
values stored should be 0 based indices within the host api's own
96
device index range (0 to deviceCount). These values will be converted
97
to global device indices by pa_front after PaUtilHostApiInitializer()
102
PaDeviceInfo** deviceInfos;
105
(*Terminate)() is guaranteed to be called with a valid <hostApi>
106
parameter, which was previously returned from the same implementation's
109
void (*Terminate)( struct PaUtilHostApiRepresentation *hostApi );
112
The inputParameters and outputParameters pointers should not be saved
113
as they will not remain valid after OpenStream is called.
116
The following guarantees are made about parameters to (*OpenStream)():
118
[NOTE: the following list up to *END PA FRONT VALIDATIONS* should be
119
kept in sync with the one for ValidateOpenStreamParameters and
120
Pa_OpenStream in pa_front.c]
122
PaHostApiRepresentation *hostApi
123
- is valid for this implementation
128
- at least one of inputParameters & outputParmeters is valid (not NULL)
130
- if inputParameters & outputParmeters are both valid, that
131
inputParameters->device & outputParmeters->device both use the same host api
133
PaDeviceIndex inputParameters->device
134
- is within range (0 to Pa_CountDevices-1) Or:
135
- is paUseHostApiSpecificDeviceSpecification and
136
inputParameters->hostApiSpecificStreamInfo is non-NULL and refers
139
int inputParameters->numChannels
140
- if inputParameters->device is not paUseHostApiSpecificDeviceSpecification, numInputChannels is > 0
141
- upper bound is NOT validated against device capabilities
143
PaSampleFormat inputParameters->sampleFormat
144
- is one of the sample formats defined in portaudio.h
146
void *inputParameters->hostApiSpecificStreamInfo
147
- if supplied its hostApi field matches the input device's host Api
149
PaDeviceIndex outputParmeters->device
150
- is within range (0 to Pa_CountDevices-1)
152
int outputParmeters->numChannels
153
- if inputDevice is valid, numInputChannels is > 0
154
- upper bound is NOT validated against device capabilities
156
PaSampleFormat outputParmeters->sampleFormat
157
- is one of the sample formats defined in portaudio.h
159
void *outputParmeters->hostApiSpecificStreamInfo
160
- if supplied its hostApi field matches the output device's host Api
163
- is not an 'absurd' rate (less than 1000. or greater than 200000.)
164
- sampleRate is NOT validated against device capabilities
166
PaStreamFlags streamFlags
167
- unused platform neutral flags are zero
168
- paNeverDropInput is only used for full-duplex callback streams
169
with variable buffer size (paFramesPerBufferUnspecified)
171
[*END PA FRONT VALIDATIONS*]
174
The following validations MUST be performed by (*OpenStream)():
176
- check that input device can support numInputChannels
178
- check that input device can support inputSampleFormat, or that
179
we have the capability to convert from outputSampleFormat to
182
- if inputStreamInfo is supplied, validate its contents,
183
or return an error if no inputStreamInfo is expected
185
- check that output device can support numOutputChannels
187
- check that output device can support outputSampleFormat, or that
188
we have the capability to convert from outputSampleFormat to
191
- if outputStreamInfo is supplied, validate its contents,
192
or return an error if no outputStreamInfo is expected
194
- if a full duplex stream is requested, check that the combination
195
of input and output parameters is supported
197
- check that the device supports sampleRate
199
- alter sampleRate to a close allowable rate if necessary
201
- validate inputLatency and outputLatency
203
- validate any platform specific flags, if flags are supplied they
206
PaError (*OpenStream)( struct PaUtilHostApiRepresentation *hostApi,
208
const PaStreamParameters *inputParameters,
209
const PaStreamParameters *outputParameters,
211
unsigned long framesPerCallback,
212
PaStreamFlags streamFlags,
213
PaStreamCallback *streamCallback,
217
PaError (*IsFormatSupported)( struct PaUtilHostApiRepresentation *hostApi,
218
const PaStreamParameters *inputParameters,
219
const PaStreamParameters *outputParameters,
221
} PaUtilHostApiRepresentation;
224
/** Prototype for the initialization function which must be implemented by every
227
This function should only return an error other than paNoError if it encounters
228
an unexpected and fatal error (memory allocation error for example). In general,
229
there may be conditions under which it returns a NULL interface pointer and also
230
returns paNoError. For example, if the ASIO implementation detects that ASIO is
231
not installed, it should return a NULL interface, and paNoError.
233
@see paHostApiInitializers
235
typedef PaError PaUtilHostApiInitializer( PaUtilHostApiRepresentation**, PaHostApiIndex );
238
/** paHostApiInitializers is a NULL-terminated array of host API initialization
239
functions. These functions are called by pa_front.c to initialize the host APIs
240
when the client calls Pa_Initialize().
242
There is a platform specific file which defines paHostApiInitializers for that
243
platform, pa_win/pa_win_hostapis.c contains the Win32 definitions for example.
245
extern PaUtilHostApiInitializer *paHostApiInitializers[];
248
/** The index of the default host API in the paHostApiInitializers array.
250
There is a platform specific file which defines paDefaultHostApiIndex for that
251
platform, see pa_win/pa_win_hostapis.c for example.
253
extern int paDefaultHostApiIndex;
258
#endif /* __cplusplus */
259
#endif /* PA_HOSTAPI_H */