Jack2  1.9.12
portaudio.h
Go to the documentation of this file.
1 
2 #ifndef PORTAUDIO_H
3 #define PORTAUDIO_H
4 /*
5  * $Id: portaudio.h,v 1.1.2.2 2006/06/20 14:44:48 letz Exp $
6  * PortAudio Portable Real-Time Audio Library
7  * PortAudio API Header File
8  * Latest version available at: http://www.portaudio.com/
9  *
10  * Copyright (c) 1999-2002 Ross Bencina and Phil Burk
11  *
12  * Permission is hereby granted, free of charge, to any person obtaining
13  * a copy of this software and associated documentation files
14  * (the "Software"), to deal in the Software without restriction,
15  * including without limitation the rights to use, copy, modify, merge,
16  * publish, distribute, sublicense, and/or sell copies of the Software,
17  * and to permit persons to whom the Software is furnished to do so,
18  * subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice shall be
21  * included in all copies or substantial portions of the Software.
22  *
23  * Any person wishing to distribute modifications to the Software is
24  * requested to send the modifications to the original developer so that
25  * they can be incorporated into the canonical version.
26  *
27  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
30  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
31  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
32  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34  */
35 
41 #ifdef __cplusplus
42 extern "C"
43 {
44 #endif /* __cplusplus */
45 
46 
50  int Pa_GetVersion( void );
51 
52 
56  const char* Pa_GetVersionText( void );
57 
58 
63  typedef int PaError;
64  typedef enum PaErrorCode {
65  paNoError = 0,
66 
67  paNotInitialized = -10000,
68  paUnanticipatedHostError,
69  paInvalidChannelCount,
70  paInvalidSampleRate,
71  paInvalidDevice,
72  paInvalidFlag,
73  paSampleFormatNotSupported,
74  paBadIODeviceCombination,
75  paInsufficientMemory,
76  paBufferTooBig,
77  paBufferTooSmall,
78  paNullCallback,
79  paBadStreamPtr,
80  paTimedOut,
81  paInternalError,
82  paDeviceUnavailable,
83  paIncompatibleHostApiSpecificStreamInfo,
84  paStreamIsStopped,
85  paStreamIsNotStopped,
86  paInputOverflowed,
87  paOutputUnderflowed,
88  paHostApiNotFound,
89  paInvalidHostApi,
94  paIncompatibleStreamHostApi,
95  paBadBufferPtr
96  }
98 
99 
103  const char *Pa_GetErrorText( PaError errorCode );
104 
105 
124  PaError Pa_Initialize( void );
125 
126 
143  PaError Pa_Terminate( void );
144 
145 
146 
153  typedef int PaDeviceIndex;
154 
155 
161 #define paNoDevice ((PaDeviceIndex)-1)
162 
163 
169 #define paUseHostApiSpecificDeviceSpecification ((PaDeviceIndex)-2)
170 
171 
172  /* Host API enumeration mechanism */
173 
179  typedef int PaHostApiIndex;
180 
181 
192 
193 
203 
204 
216  typedef enum PaHostApiTypeId {
217  paInDevelopment = 0, /* use while developing support for a new host API */
218  paDirectSound = 1,
219  paMME = 2,
220  paASIO = 3,
221  paSoundManager = 4,
222  paCoreAudio = 5,
223  paOSS = 7,
224  paALSA = 8,
225  paAL = 9,
226  paBeOS = 10,
227  paWDMKS = 11,
228  paJACK = 12,
229  paWASAPI = 13
230  }
232 
233 
236  typedef struct PaHostApiInfo {
242  const char *name;
243 
250 
256 
262 
263  }
265 
266 
281 
282 
299 
300 
323  int hostApiDeviceIndex );
324 
325 
326 
329  typedef struct PaHostErrorInfo {
331  long errorCode;
332  const char *errorText;
333  }
335 
336 
351 
352 
353 
354  /* Device enumeration and capabilities */
355 
364 
365 
373 
374 
391 
392 
399  typedef double PaTime;
400 
401 
421  typedef unsigned long PaSampleFormat;
422 
423 
424 #define paFloat32 ((PaSampleFormat) 0x00000001)
425 #define paInt32 ((PaSampleFormat) 0x00000002)
426 #define paInt24 ((PaSampleFormat) 0x00000004)
427 #define paInt16 ((PaSampleFormat) 0x00000008)
428 #define paInt8 ((PaSampleFormat) 0x00000010)
429 #define paUInt8 ((PaSampleFormat) 0x00000020)
430 #define paCustomFormat ((PaSampleFormat) 0x00010000)
432 #define paNonInterleaved ((PaSampleFormat) 0x80000000)
433 
437  typedef struct PaDeviceInfo {
438  int structVersion; /* this is struct version 2 */
439  const char *name;
440  PaHostApiIndex hostApi; /* note this is a host API index, not a type id*/
441 
442  int maxInputChannels;
443  int maxOutputChannels;
444 
445  /* Default latency values for interactive performance. */
446  PaTime defaultLowInputLatency;
447  PaTime defaultLowOutputLatency;
448  /* Default latency values for robust non-interactive applications (eg. playing sound files). */
449  PaTime defaultHighInputLatency;
450  PaTime defaultHighOutputLatency;
451 
452  double defaultSampleRate;
453  }
454  PaDeviceInfo;
455 
456 
471 
472 
475  typedef struct PaStreamParameters {
483 
490 
496 
509 
516 
517  }
519 
520 
522 #define paFormatIsSupported (0)
523 
546  PaError Pa_IsFormatSupported( const PaStreamParameters *inputParameters,
547  const PaStreamParameters *outputParameters,
548  double sampleRate );
549 
550 
551 
552  /* Streaming types and functions */
553 
554 
572  typedef void PaStream;
573 
574 
579 #define paFramesPerBufferUnspecified (0)
580 
581 
590  typedef unsigned long PaStreamFlags;
591 
593 #define paNoFlag ((PaStreamFlags) 0)
594 
598 #define paClipOff ((PaStreamFlags) 0x00000001)
599 
603 #define paDitherOff ((PaStreamFlags) 0x00000002)
604 
614 #define paNeverDropInput ((PaStreamFlags) 0x00000004)
615 
622 #define paPrimeOutputBuffersUsingStreamCallback ((PaStreamFlags) 0x00000008)
623 
627 #define paPlatformSpecificFlags ((PaStreamFlags)0xFFFF0000)
628 
632  typedef struct PaStreamCallbackTimeInfo {
633  PaTime inputBufferAdcTime;
634  PaTime currentTime;
635  PaTime outputBufferDacTime;
636  }
638 
639 
646  typedef unsigned long PaStreamCallbackFlags;
647 
655 #define paInputUnderflow ((PaStreamCallbackFlags) 0x00000001)
656 
664 #define paInputOverflow ((PaStreamCallbackFlags) 0x00000002)
665 
670 #define paOutputUnderflow ((PaStreamCallbackFlags) 0x00000004)
671 
675 #define paOutputOverflow ((PaStreamCallbackFlags) 0x00000008)
676 
681 #define paPrimingOutput ((PaStreamCallbackFlags) 0x00000010)
682 
688  {
689  paContinue = 0,
690  paComplete = 1,
691  paAbort = 2
693 
694 
739  typedef int PaStreamCallback(
740  const void *input, void *output,
741  unsigned long frameCount,
742  const PaStreamCallbackTimeInfo* timeInfo,
743  PaStreamCallbackFlags statusFlags,
744  void *userData );
745 
746 
801  PaError Pa_OpenStream( PaStream** stream,
802  const PaStreamParameters *inputParameters,
803  const PaStreamParameters *outputParameters,
804  double sampleRate,
805  unsigned long framesPerBuffer,
806  PaStreamFlags streamFlags,
807  PaStreamCallback *streamCallback,
808  void *userData );
809 
810 
842  int numInputChannels,
843  int numOutputChannels,
844  PaSampleFormat sampleFormat,
845  double sampleRate,
846  unsigned long framesPerBuffer,
847  PaStreamCallback *streamCallback,
848  void *userData );
849 
850 
854  PaError Pa_CloseStream( PaStream *stream );
855 
856 
871  typedef void PaStreamFinishedCallback( void *userData );
872 
873 
892  PaError Pa_SetStreamFinishedCallback( PaStream *stream, PaStreamFinishedCallback* streamFinishedCallback );
893 
894 
897  PaError Pa_StartStream( PaStream *stream );
898 
899 
903  PaError Pa_StopStream( PaStream *stream );
904 
905 
909  PaError Pa_AbortStream( PaStream *stream );
910 
911 
925 
926 
941 
942 
943 
948  typedef struct PaStreamInfo {
951 
959 
967 
975  double sampleRate;
976 
977  }
978  PaStreamInfo;
979 
980 
994  const PaStreamInfo* Pa_GetStreamInfo( PaStream *stream );
995 
996 
1005  PaTime Pa_GetStreamTime( PaStream *stream );
1006 
1007 
1024  double Pa_GetStreamCpuLoad( PaStream* stream );
1025 
1026 
1048  PaError Pa_ReadStream( PaStream* stream,
1049  void *buffer,
1050  unsigned long frames );
1051 
1052 
1075  PaError Pa_WriteStream( PaStream* stream,
1076  const void *buffer,
1077  unsigned long frames );
1078 
1079 
1088  signed long Pa_GetStreamReadAvailable( PaStream* stream );
1089 
1090 
1099  signed long Pa_GetStreamWriteAvailable( PaStream* stream );
1100 
1101 
1102  /* Miscellaneous utilities */
1103 
1104 
1111 
1112 
1120  void Pa_Sleep( long msec );
1121 
1122 
1123 
1124 #ifdef __cplusplus
1125 }
1126 #endif /* __cplusplus */
1127 #endif /* PORTAUDIO_H */
PaStreamInfo::structVersion
int structVersion
Definition: portaudio.h:950
PaStreamInfo::sampleRate
double sampleRate
Definition: portaudio.h:975
PaHostApiInfo::structVersion
int structVersion
Definition: portaudio.h:238
PaStreamCallbackResult
PaStreamCallbackResult
Definition: portaudio.h:687
PaHostApiInfo
struct PaHostApiInfo PaHostApiInfo
PaHostApiIndex
int PaHostApiIndex
Definition: portaudio.h:179
PaHostErrorInfo
struct PaHostErrorInfo PaHostErrorInfo
PaStreamInfo
Definition: portaudio.h:948
PaStreamParameters::channelCount
int channelCount
Definition: portaudio.h:489
Pa_GetDefaultInputDevice
PaDeviceIndex Pa_GetDefaultInputDevice(void)
Pa_GetVersion
int Pa_GetVersion(void)
PaStreamParameters::sampleFormat
PaSampleFormat sampleFormat
Definition: portaudio.h:495
PaStreamInfo::inputLatency
PaTime inputLatency
Definition: portaudio.h:958
paCanNotReadFromACallbackStream
Definition: portaudio.h:90
PaDeviceInfo
struct PaDeviceInfo PaDeviceInfo
PaTime
double PaTime
Definition: portaudio.h:399
Pa_IsFormatSupported
PaError Pa_IsFormatSupported(const PaStreamParameters *inputParameters, const PaStreamParameters *outputParameters, double sampleRate)
Pa_GetStreamCpuLoad
double Pa_GetStreamCpuLoad(PaStream *stream)
Pa_GetVersionText
const char * Pa_GetVersionText(void)
PaHostApiTypeId
PaHostApiTypeId
Definition: portaudio.h:216
Pa_CloseStream
PaError Pa_CloseStream(PaStream *stream)
PaStreamParameters::hostApiSpecificStreamInfo
void * hostApiSpecificStreamInfo
Definition: portaudio.h:515
PaDeviceInfo
Definition: portaudio.h:437
Pa_GetHostApiCount
PaHostApiIndex Pa_GetHostApiCount(void)
PaStreamCallback
int PaStreamCallback(const void *input, void *output, unsigned long frameCount, const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData)
Definition: portaudio.h:739
Pa_Sleep
void Pa_Sleep(long msec)
Pa_GetSampleSize
PaError Pa_GetSampleSize(PaSampleFormat format)
Pa_GetErrorText
const char * Pa_GetErrorText(PaError errorCode)
Pa_StartStream
PaError Pa_StartStream(PaStream *stream)
PaHostApiInfo::defaultOutputDevice
PaDeviceIndex defaultOutputDevice
Definition: portaudio.h:261
Pa_Terminate
PaError Pa_Terminate(void)
Pa_AbortStream
PaError Pa_AbortStream(PaStream *stream)
PaStreamInfo
struct PaStreamInfo PaStreamInfo
PaStreamParameters
struct PaStreamParameters PaStreamParameters
Pa_GetStreamInfo
const PaStreamInfo * Pa_GetStreamInfo(PaStream *stream)
Pa_Initialize
PaError Pa_Initialize(void)
PaStreamParameters::suggestedLatency
PaTime suggestedLatency
Definition: portaudio.h:508
Pa_GetDefaultHostApi
PaHostApiIndex Pa_GetDefaultHostApi(void)
PaHostErrorInfo
Definition: portaudio.h:329
PaStreamInfo::outputLatency
PaTime outputLatency
Definition: portaudio.h:966
PaStream
void PaStream
Definition: portaudio.h:572
Pa_OpenStream
PaError Pa_OpenStream(PaStream **stream, const PaStreamParameters *inputParameters, const PaStreamParameters *outputParameters, double sampleRate, unsigned long framesPerBuffer, PaStreamFlags streamFlags, PaStreamCallback *streamCallback, void *userData)
Pa_IsStreamActive
PaError Pa_IsStreamActive(PaStream *stream)
PaErrorCode
PaErrorCode
Definition: portaudio.h:64
Pa_GetDeviceInfo
const PaDeviceInfo * Pa_GetDeviceInfo(PaDeviceIndex device)
PaHostApiInfo
Definition: portaudio.h:236
PaStreamFinishedCallback
void PaStreamFinishedCallback(void *userData)
Definition: portaudio.h:871
Pa_IsStreamStopped
PaError Pa_IsStreamStopped(PaStream *stream)
PaHostApiInfo::deviceCount
int deviceCount
Definition: portaudio.h:249
Pa_WriteStream
PaError Pa_WriteStream(PaStream *stream, const void *buffer, unsigned long frames)
PaStreamParameters::device
PaDeviceIndex device
Definition: portaudio.h:482
Pa_GetDeviceCount
PaDeviceIndex Pa_GetDeviceCount(void)
PaHostApiInfo::type
PaHostApiTypeId type
Definition: portaudio.h:240
Pa_GetStreamTime
PaTime Pa_GetStreamTime(PaStream *stream)
PaHostApiInfo::name
const char * name
Definition: portaudio.h:242
paCanNotWriteToAnInputOnlyStream
Definition: portaudio.h:93
PaHostApiInfo::defaultInputDevice
PaDeviceIndex defaultInputDevice
Definition: portaudio.h:255
Pa_SetStreamFinishedCallback
PaError Pa_SetStreamFinishedCallback(PaStream *stream, PaStreamFinishedCallback *streamFinishedCallback)
PaHostErrorInfo::errorCode
long errorCode
Definition: portaudio.h:331
PaSampleFormat
unsigned long PaSampleFormat
Definition: portaudio.h:421
paCanNotReadFromAnOutputOnlyStream
Definition: portaudio.h:92
Pa_GetStreamWriteAvailable
signed long Pa_GetStreamWriteAvailable(PaStream *stream)
Pa_StopStream
PaError Pa_StopStream(PaStream *stream)
Pa_HostApiDeviceIndexToDeviceIndex
PaDeviceIndex Pa_HostApiDeviceIndexToDeviceIndex(PaHostApiIndex hostApi, int hostApiDeviceIndex)
Pa_ReadStream
PaError Pa_ReadStream(PaStream *stream, void *buffer, unsigned long frames)
PaError
int PaError
Definition: portaudio.h:63
PaStreamParameters
Definition: portaudio.h:475
paCanNotWriteToACallbackStream
Definition: portaudio.h:91
PaDeviceIndex
int PaDeviceIndex
Definition: portaudio.h:153
PaStreamFlags
unsigned long PaStreamFlags
Definition: portaudio.h:590
Pa_GetLastHostErrorInfo
const PaHostErrorInfo * Pa_GetLastHostErrorInfo(void)
PaHostErrorInfo::errorText
const char * errorText
Definition: portaudio.h:332
Pa_HostApiTypeIdToHostApiIndex
PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex(PaHostApiTypeId type)
PaStreamCallbackTimeInfo
Definition: portaudio.h:632
Pa_OpenDefaultStream
PaError Pa_OpenDefaultStream(PaStream **stream, int numInputChannels, int numOutputChannels, PaSampleFormat sampleFormat, double sampleRate, unsigned long framesPerBuffer, PaStreamCallback *streamCallback, void *userData)
Pa_GetStreamReadAvailable
signed long Pa_GetStreamReadAvailable(PaStream *stream)
PaStreamCallbackTimeInfo
struct PaStreamCallbackTimeInfo PaStreamCallbackTimeInfo
Pa_GetHostApiInfo
const PaHostApiInfo * Pa_GetHostApiInfo(PaHostApiIndex hostApi)
PaStreamCallbackFlags
unsigned long PaStreamCallbackFlags
Definition: portaudio.h:646
Pa_GetDefaultOutputDevice
PaDeviceIndex Pa_GetDefaultOutputDevice(void)
PaHostErrorInfo::hostApiType
PaHostApiTypeId hostApiType
Definition: portaudio.h:330