PortAudio 2.0
portaudio.h
Go to the documentation of this file.
1#ifndef PORTAUDIO_H
2#define PORTAUDIO_H
3/*
4 * $Id$
5 * PortAudio Portable Real-Time Audio Library
6 * PortAudio API Header File
7 * Latest version available at: http://www.portaudio.com/
8 *
9 * Copyright (c) 1999-2002 Ross Bencina and 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 * 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.
29 */
30
31/*
32 * The text above constitutes the entire PortAudio license; however,
33 * the PortAudio community also makes the following non-binding requests:
34 *
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
39 * license above.
40 */
41
48#ifdef __cplusplus
49extern "C"
50{
51#endif /* __cplusplus */
52
58int Pa_GetVersion( void );
59
67const char* Pa_GetVersionText( void );
68
81#define paMakeVersionNumber(major, minor, subminor) \
82 (((major)&0xFF)<<16 | ((minor)&0xFF)<<8 | ((subminor)&0xFF))
83
84
90typedef struct PaVersionInfo {
91 int versionMajor;
92 int versionMinor;
93 int versionSubMinor;
102 const char *versionText;
104
116
117
122typedef int PaError;
123typedef enum PaErrorCode
124{
125 paNoError = 0,
126
127 paNotInitialized = -10000,
128 paUnanticipatedHostError,
129 paInvalidChannelCount,
130 paInvalidSampleRate,
131 paInvalidDevice,
132 paInvalidFlag,
133 paSampleFormatNotSupported,
134 paBadIODeviceCombination,
135 paInsufficientMemory,
136 paBufferTooBig,
137 paBufferTooSmall,
138 paNullCallback,
139 paBadStreamPtr,
140 paTimedOut,
141 paInternalError,
142 paDeviceUnavailable,
143 paIncompatibleHostApiSpecificStreamInfo,
144 paStreamIsStopped,
145 paStreamIsNotStopped,
146 paInputOverflowed,
147 paOutputUnderflowed,
148 paHostApiNotFound,
149 paInvalidHostApi,
150 paCanNotReadFromACallbackStream,
151 paCanNotWriteToACallbackStream,
152 paCanNotReadFromAnOutputOnlyStream,
153 paCanNotWriteToAnInputOnlyStream,
154 paIncompatibleStreamHostApi,
155 paBadBufferPtr,
156 paCanNotInitializeRecursively
157} PaErrorCode;
158
159
163const char *Pa_GetErrorText( PaError errorCode );
164
165
186
187
205
206
207
214typedef int PaDeviceIndex;
215
216
222#define paNoDevice ((PaDeviceIndex)-1)
223
224
230#define paUseHostApiSpecificDeviceSpecification ((PaDeviceIndex)-2)
231
232
233/* Host API enumeration mechanism */
234
240typedef int PaHostApiIndex;
241
242
253
254
264
265
277typedef enum PaHostApiTypeId
278{
279 paInDevelopment=0, /* use while developing support for a new host API */
280 paDirectSound=1,
281 paMME=2,
282 paASIO=3,
283 paSoundManager=4,
284 paCoreAudio=5,
285 paOSS=7,
286 paALSA=8,
287 paAL=9,
288 paBeOS=10,
289 paWDMKS=11,
290 paJACK=12,
291 paWASAPI=13,
292 paAudioScienceHPI=14,
293 paAudioIO=15,
294 paPulseAudio=16,
295 paSndio=17
297
298
330
331
346
347
364
365
388 int hostApiDeviceIndex );
389
390
391
399
400
415
416
417
418/* Device enumeration and capabilities */
419
428
429
437
438
455
456
465typedef double PaTime;
466
467
489typedef unsigned long PaSampleFormat;
490
491
492#define paFloat32 ((PaSampleFormat) 0x00000001)
493#define paInt32 ((PaSampleFormat) 0x00000002)
494#define paInt24 ((PaSampleFormat) 0x00000004)
495#define paInt16 ((PaSampleFormat) 0x00000008)
496#define paInt8 ((PaSampleFormat) 0x00000010)
497#define paUInt8 ((PaSampleFormat) 0x00000020)
498#define paCustomFormat ((PaSampleFormat) 0x00010000)
500#define paNonInterleaved ((PaSampleFormat) 0x80000000)
505typedef struct PaDeviceInfo
506{
510 const char *name;
511
514
515 int maxInputChannels;
516 int maxOutputChannels;
517
520 PaTime defaultLowOutputLatency;
523 PaTime defaultHighOutputLatency;
524
525 double defaultSampleRate;
527
528
543
544
590
591
593#define paFormatIsSupported (0)
594
618 const PaStreamParameters *outputParameters,
619 double sampleRate );
620
621
622
623/* Streaming types and functions */
624
625
643typedef void PaStream;
644
645
650#define paFramesPerBufferUnspecified (0)
651
652
661typedef unsigned long PaStreamFlags;
662
664#define paNoFlag ((PaStreamFlags) 0)
665
669#define paClipOff ((PaStreamFlags) 0x00000001)
670
674#define paDitherOff ((PaStreamFlags) 0x00000002)
675
685#define paNeverDropInput ((PaStreamFlags) 0x00000004)
686
693#define paPrimeOutputBuffersUsingStreamCallback ((PaStreamFlags) 0x00000008)
694
698#define paPlatformSpecificFlags ((PaStreamFlags)0xFFFF0000)
699
712
713
720typedef unsigned long PaStreamCallbackFlags;
721
729#define paInputUnderflow ((PaStreamCallbackFlags) 0x00000001)
730
738#define paInputOverflow ((PaStreamCallbackFlags) 0x00000002)
739
744#define paOutputUnderflow ((PaStreamCallbackFlags) 0x00000004)
745
749#define paOutputOverflow ((PaStreamCallbackFlags) 0x00000008)
750
755#define paPrimingOutput ((PaStreamCallbackFlags) 0x00000010)
756
767
768
839 const void *input, void *output,
840 unsigned long frameCount,
841 const PaStreamCallbackTimeInfo* timeInfo,
842 PaStreamCallbackFlags statusFlags,
843 void *userData );
844
845
904 const PaStreamParameters *inputParameters,
905 const PaStreamParameters *outputParameters,
906 double sampleRate,
907 unsigned long framesPerBuffer,
908 PaStreamFlags streamFlags,
909 PaStreamCallback *streamCallback,
910 void *userData );
911
912
944 int numInputChannels,
945 int numOutputChannels,
946 PaSampleFormat sampleFormat,
947 double sampleRate,
948 unsigned long framesPerBuffer,
949 PaStreamCallback *streamCallback,
950 void *userData );
951
952
957
958
973typedef void PaStreamFinishedCallback( void *userData );
974
975
995
996
1000
1001
1006
1007
1012
1013
1027
1028
1043
1044
1045
1081
1082
1097
1098
1115
1116
1134
1135
1162 void *buffer,
1163 unsigned long frames );
1164
1165
1193 const void *buffer,
1194 unsigned long frames );
1195
1196
1209
1210
1223
1224
1225/* Miscellaneous utilities */
1226
1227
1234
1235
1243void Pa_Sleep( long msec );
1244
1245
1246
1247#ifdef __cplusplus
1248}
1249#endif /* __cplusplus */
1250#endif /* PORTAUDIO_H */
PaError Pa_WriteStream(PaStream *stream, const void *buffer, unsigned long frames)
PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex(PaHostApiTypeId type)
PaError Pa_OpenDefaultStream(PaStream **stream, int numInputChannels, int numOutputChannels, PaSampleFormat sampleFormat, double sampleRate, unsigned long framesPerBuffer, PaStreamCallback *streamCallback, void *userData)
PaError Pa_ReadStream(PaStream *stream, void *buffer, unsigned long frames)
PaError Pa_Terminate(void)
PaError Pa_AbortStream(PaStream *stream)
struct PaStreamCallbackTimeInfo PaStreamCallbackTimeInfo
void PaStream
Definition portaudio.h:643
PaHostApiIndex Pa_GetHostApiCount(void)
void Pa_Sleep(long msec)
const PaHostErrorInfo * Pa_GetLastHostErrorInfo(void)
PaError Pa_IsStreamActive(PaStream *stream)
signed long Pa_GetStreamWriteAvailable(PaStream *stream)
PaTime Pa_GetStreamTime(PaStream *stream)
unsigned long PaStreamFlags
Definition portaudio.h:661
struct PaVersionInfo PaVersionInfo
PaError Pa_OpenStream(PaStream **stream, const PaStreamParameters *inputParameters, const PaStreamParameters *outputParameters, double sampleRate, unsigned long framesPerBuffer, PaStreamFlags streamFlags, PaStreamCallback *streamCallback, void *userData)
unsigned long PaSampleFormat
Definition portaudio.h:489
int PaError
Definition portaudio.h:122
PaError Pa_IsStreamStopped(PaStream *stream)
PaError Pa_GetSampleSize(PaSampleFormat format)
PaDeviceIndex Pa_HostApiDeviceIndexToDeviceIndex(PaHostApiIndex hostApi, int hostApiDeviceIndex)
unsigned long PaStreamCallbackFlags
Definition portaudio.h:720
const char * Pa_GetVersionText(void)
struct PaStreamInfo PaStreamInfo
int Pa_GetVersion(void)
struct PaDeviceInfo PaDeviceInfo
PaError Pa_StartStream(PaStream *stream)
double Pa_GetStreamCpuLoad(PaStream *stream)
int PaStreamCallback(const void *input, void *output, unsigned long frameCount, const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
Definition portaudio.h:838
PaHostApiTypeId
Definition portaudio.h:278
PaError Pa_CloseStream(PaStream *stream)
const PaVersionInfo * Pa_GetVersionInfo(void)
struct PaStreamParameters PaStreamParameters
PaError Pa_SetStreamFinishedCallback(PaStream *stream, PaStreamFinishedCallback *streamFinishedCallback)
struct PaHostErrorInfo PaHostErrorInfo
void PaStreamFinishedCallback(void *userData)
Definition portaudio.h:973
const PaDeviceInfo * Pa_GetDeviceInfo(PaDeviceIndex device)
const PaStreamInfo * Pa_GetStreamInfo(PaStream *stream)
PaError Pa_IsFormatSupported(const PaStreamParameters *inputParameters, const PaStreamParameters *outputParameters, double sampleRate)
PaError Pa_Initialize(void)
PaDeviceIndex Pa_GetDefaultInputDevice(void)
PaDeviceIndex Pa_GetDeviceCount(void)
signed long Pa_GetStreamReadAvailable(PaStream *stream)
int PaDeviceIndex
Definition portaudio.h:214
PaDeviceIndex Pa_GetDefaultOutputDevice(void)
struct PaHostApiInfo PaHostApiInfo
PaHostApiIndex Pa_GetDefaultHostApi(void)
const char * Pa_GetErrorText(PaError errorCode)
PaStreamCallbackResult
Definition portaudio.h:762
@ paComplete
Definition portaudio.h:764
@ paAbort
Definition portaudio.h:765
@ paContinue
Definition portaudio.h:763
int PaHostApiIndex
Definition portaudio.h:240
double PaTime
Definition portaudio.h:465
PaError Pa_StopStream(PaStream *stream)
const PaHostApiInfo * Pa_GetHostApiInfo(PaHostApiIndex hostApi)
const char * name
Definition portaudio.h:510
int structVersion
Definition portaudio.h:507
PaTime defaultHighInputLatency
Definition portaudio.h:522
PaTime defaultLowInputLatency
Definition portaudio.h:519
PaHostApiIndex hostApi
Definition portaudio.h:513
PaHostApiTypeId type
Definition portaudio.h:306
PaDeviceIndex defaultOutputDevice
Definition portaudio.h:327
const char * name
Definition portaudio.h:308
PaDeviceIndex defaultInputDevice
Definition portaudio.h:321
const char * errorText
Definition portaudio.h:397
PaHostApiTypeId hostApiType
Definition portaudio.h:395
PaTime inputLatency
Definition portaudio.h:1061
PaTime outputLatency
Definition portaudio.h:1069
double sampleRate
Definition portaudio.h:1078
PaTime suggestedLatency
Definition portaudio.h:580
PaSampleFormat sampleFormat
Definition portaudio.h:568
PaDeviceIndex device
Definition portaudio.h:555
void * hostApiSpecificStreamInfo
Definition portaudio.h:587
const char * versionControlRevision
Definition portaudio.h:100
const char * versionText
Definition portaudio.h:102