comparison osx/include/portaudio.h @ 56:af97cad61ff0

Add updated build of PortAudio for OSX
author Chris Cannam <cannam@all-day-breakfast.com>
date Tue, 03 Jan 2017 15:10:52 +0000
parents 27d4e7152c95
children
comparison
equal deleted inserted replaced
55:284acf908dcd 56:af97cad61ff0
1 #ifndef PORTAUDIO_H 1 #ifndef PORTAUDIO_H
2 #define PORTAUDIO_H 2 #define PORTAUDIO_H
3 /* 3 /*
4 * $Id: portaudio.h 1594 2011-02-05 14:33:29Z rossb $ 4 * $Id$
5 * PortAudio Portable Real-Time Audio Library 5 * PortAudio Portable Real-Time Audio Library
6 * PortAudio API Header File 6 * PortAudio API Header File
7 * Latest version available at: http://www.portaudio.com/ 7 * Latest version available at: http://www.portaudio.com/
8 * 8 *
9 * Copyright (c) 1999-2002 Ross Bencina and Phil Burk 9 * Copyright (c) 1999-2002 Ross Bencina and Phil Burk
48 #ifdef __cplusplus 48 #ifdef __cplusplus
49 extern "C" 49 extern "C"
50 { 50 {
51 #endif /* __cplusplus */ 51 #endif /* __cplusplus */
52 52
53 53 /** Retrieve the release number of the currently running PortAudio build.
54 /** Retrieve the release number of the currently running PortAudio build, 54 For example, for version "19.5.1" this will return 0x00130501.
55 eg 1900. 55
56 @see paMakeVersionNumber
56 */ 57 */
57 int Pa_GetVersion( void ); 58 int Pa_GetVersion( void );
58 59
59
60 /** Retrieve a textual description of the current PortAudio build, 60 /** Retrieve a textual description of the current PortAudio build,
61 eg "PortAudio V19-devel 13 October 2002". 61 e.g. "PortAudio V19.5.0-devel, revision 1952M".
62 The format of the text may change in the future. Do not try to parse the
63 returned string.
64
65 @deprecated As of 19.5.0, use Pa_GetVersionInfo()->versionText instead.
62 */ 66 */
63 const char* Pa_GetVersionText( void ); 67 const char* Pa_GetVersionText( void );
68
69 /**
70 Generate a packed integer version number in the same format used
71 by Pa_GetVersion(). Use this to compare a specified version number with
72 the currently running version. For example:
73
74 @code
75 if( Pa_GetVersion() < paMakeVersionNumber(19,5,1) ) {}
76 @endcode
77
78 @see Pa_GetVersion, Pa_GetVersionInfo
79 @version Available as of 19.5.0.
80 */
81 #define paMakeVersionNumber(major, minor, subminor) \
82 (((major)&0xFF)<<16 | ((minor)&0xFF)<<8 | ((subminor)&0xFF))
83
84
85 /**
86 A structure containing PortAudio API version information.
87 @see Pa_GetVersionInfo, paMakeVersionNumber
88 @version Available as of 19.5.0.
89 */
90 typedef struct PaVersionInfo {
91 int versionMajor;
92 int versionMinor;
93 int versionSubMinor;
94 /**
95 This is currently the Git revision hash but may change in the future.
96 The versionControlRevision is updated by running a script before compiling the library.
97 If the update does not occur, this value may refer to an earlier revision.
98 */
99 const char *versionControlRevision;
100 /** Version as a string, for example "PortAudio V19.5.0-devel, revision 1952M" */
101 const char *versionText;
102 } PaVersionInfo;
103
104 /** Retrieve version information for the currently running PortAudio build.
105 @return A pointer to an immutable PaVersionInfo structure.
106
107 @note This function can be called at any time. It does not require PortAudio
108 to be initialized. The structure pointed to is statically allocated. Do not
109 attempt to free it or modify it.
110
111 @see PaVersionInfo, paMakeVersionNumber
112 @version Available as of 19.5.0.
113 */
114 const PaVersionInfo* Pa_GetVersionInfo();
64 115
65 116
66 /** Error codes returned by PortAudio functions. 117 /** Error codes returned by PortAudio functions.
67 Note that with the exception of paNoError, all PaErrorCodes are negative. 118 Note that with the exception of paNoError, all PaErrorCodes are negative.
68 */ 119 */
448 */ 499 */
449 typedef struct PaDeviceInfo 500 typedef struct PaDeviceInfo
450 { 501 {
451 int structVersion; /* this is struct version 2 */ 502 int structVersion; /* this is struct version 2 */
452 const char *name; 503 const char *name;
453 PaHostApiIndex hostApi; /* note this is a host API index, not a type id*/ 504 PaHostApiIndex hostApi; /**< note this is a host API index, not a type id*/
454 505
455 int maxInputChannels; 506 int maxInputChannels;
456 int maxOutputChannels; 507 int maxOutputChannels;
457 508
458 /* Default latency values for interactive performance. */ 509 /** Default latency values for interactive performance. */
459 PaTime defaultLowInputLatency; 510 PaTime defaultLowInputLatency;
460 PaTime defaultLowOutputLatency; 511 PaTime defaultLowOutputLatency;
461 /* Default latency values for robust non-interactive applications (eg. playing sound files). */ 512 /** Default latency values for robust non-interactive applications (eg. playing sound files). */
462 PaTime defaultHighInputLatency; 513 PaTime defaultHighInputLatency;
463 PaTime defaultHighOutputLatency; 514 PaTime defaultHighOutputLatency;
464 515
465 double defaultSampleRate; 516 double defaultSampleRate;
466 } PaDeviceInfo; 517 } PaDeviceInfo;
638 */ 689 */
639 #define paPlatformSpecificFlags ((PaStreamFlags)0xFFFF0000) 690 #define paPlatformSpecificFlags ((PaStreamFlags)0xFFFF0000)
640 691
641 /** 692 /**
642 Timing information for the buffers passed to the stream callback. 693 Timing information for the buffers passed to the stream callback.
694
695 Time values are expressed in seconds and are synchronised with the time base used by Pa_GetStreamTime() for the associated stream.
696
697 @see PaStreamCallback, Pa_GetStreamTime
643 */ 698 */
644 typedef struct PaStreamCallbackTimeInfo{ 699 typedef struct PaStreamCallbackTimeInfo{
645 PaTime inputBufferAdcTime; 700 PaTime inputBufferAdcTime; /**< The time when the first sample of the input buffer was captured at the ADC input */
646 PaTime currentTime; 701 PaTime currentTime; /**< The time when the stream callback was invoked */
647 PaTime outputBufferDacTime; 702 PaTime outputBufferDacTime; /**< The time when the first sample of the output buffer will output the DAC */
648 } PaStreamCallbackTimeInfo; 703 } PaStreamCallbackTimeInfo;
649 704
650 705
651 /** 706 /**
652 Flag bit constants for the statusFlags to PaStreamCallback. 707 Flag bit constants for the statusFlags to PaStreamCallback.
695 Allowable return values for the PaStreamCallback. 750 Allowable return values for the PaStreamCallback.
696 @see PaStreamCallback 751 @see PaStreamCallback
697 */ 752 */
698 typedef enum PaStreamCallbackResult 753 typedef enum PaStreamCallbackResult
699 { 754 {
700 paContinue=0, 755 paContinue=0, /**< Signal that the stream should continue invoking the callback and processing audio. */
701 paComplete=1, 756 paComplete=1, /**< Signal that the stream should stop invoking the callback and finish once all output samples have played. */
702 paAbort=2 757 paAbort=2 /**< Signal that the stream should stop invoking the callback and finish as soon as possible. */
703 } PaStreamCallbackResult; 758 } PaStreamCallbackResult;
704 759
705 760
706 /** 761 /**
707 Functions of type PaStreamCallback are implemented by PortAudio clients. 762 Functions of type PaStreamCallback are implemented by PortAudio clients.
708 They consume, process or generate audio in response to requests from an 763 They consume, process or generate audio in response to requests from an
709 active PortAudio stream. 764 active PortAudio stream.
765
766 When a stream is running, PortAudio calls the stream callback periodically.
767 The callback function is responsible for processing buffers of audio samples
768 passed via the input and output parameters.
769
770 The PortAudio stream callback runs at very high or real-time priority.
771 It is required to consistently meet its time deadlines. Do not allocate
772 memory, access the file system, call library functions or call other functions
773 from the stream callback that may block or take an unpredictable amount of
774 time to complete.
775
776 In order for a stream to maintain glitch-free operation the callback
777 must consume and return audio data faster than it is recorded and/or
778 played. PortAudio anticipates that each callback invocation may execute for
779 a duration approaching the duration of frameCount audio frames at the stream
780 sample rate. It is reasonable to expect to be able to utilise 70% or more of
781 the available CPU time in the PortAudio callback. However, due to buffer size
782 adaption and other factors, not all host APIs are able to guarantee audio
783 stability under heavy CPU load with arbitrary fixed callback buffer sizes.
784 When high callback CPU utilisation is required the most robust behavior
785 can be achieved by using paFramesPerBufferUnspecified as the
786 Pa_OpenStream() framesPerBuffer parameter.
710 787
711 @param input and @param output are either arrays of interleaved samples or; 788 @param input and @param output are either arrays of interleaved samples or;
712 if non-interleaved samples were requested using the paNonInterleaved sample 789 if non-interleaved samples were requested using the paNonInterleaved sample
713 format flag, an array of buffer pointers, one non-interleaved buffer for 790 format flag, an array of buffer pointers, one non-interleaved buffer for
714 each channel. 791 each channel.
717 determined by parameters to Pa_OpenStream(). 794 determined by parameters to Pa_OpenStream().
718 795
719 @param frameCount The number of sample frames to be processed by 796 @param frameCount The number of sample frames to be processed by
720 the stream callback. 797 the stream callback.
721 798
722 @param timeInfo The time in seconds when the first sample of the input 799 @param timeInfo Timestamps indicating the ADC capture time of the first sample
723 buffer was received at the audio input, the time in seconds when the first 800 in the input buffer, the DAC output time of the first sample in the output buffer
724 sample of the output buffer will begin being played at the audio output, and 801 and the time the callback was invoked.
725 the time in seconds when the stream callback was called. 802 See PaStreamCallbackTimeInfo and Pa_GetStreamTime()
726 See also Pa_GetStreamTime()
727 803
728 @param statusFlags Flags indicating whether input and/or output buffers 804 @param statusFlags Flags indicating whether input and/or output buffers
729 have been inserted or will be dropped to overcome underflow or overflow 805 have been inserted or will be dropped to overcome underflow or overflow
730 conditions. 806 conditions.
731 807
732 @param userData The value of a user supplied pointer passed to 808 @param userData The value of a user supplied pointer passed to
733 Pa_OpenStream() intended for storing synthesis data etc. 809 Pa_OpenStream() intended for storing synthesis data etc.
734 810
735 @return 811 @return
736 The stream callback should return one of the values in the 812 The stream callback should return one of the values in the
737 PaStreamCallbackResult enumeration. To ensure that the callback continues 813 ::PaStreamCallbackResult enumeration. To ensure that the callback continues
738 to be called, it should return paContinue (0). Either paComplete or paAbort 814 to be called, it should return paContinue (0). Either paComplete or paAbort
739 can be returned to finish stream processing, after either of these values is 815 can be returned to finish stream processing, after either of these values is
740 returned the callback will not be called again. If paAbort is returned the 816 returned the callback will not be called again. If paAbort is returned the
741 stream will finish as soon as possible. If paComplete is returned, the stream 817 stream will finish as soon as possible. If paComplete is returned, the stream
742 will continue until all buffers generated by the callback have been played. 818 will continue until all buffers generated by the callback have been played.
873 clients. They can be registered with a stream using the Pa_SetStreamFinishedCallback 949 clients. They can be registered with a stream using the Pa_SetStreamFinishedCallback
874 function. Once registered they are called when the stream becomes inactive 950 function. Once registered they are called when the stream becomes inactive
875 (ie once a call to Pa_StopStream() will not block). 951 (ie once a call to Pa_StopStream() will not block).
876 A stream will become inactive after the stream callback returns non-zero, 952 A stream will become inactive after the stream callback returns non-zero,
877 or when Pa_StopStream or Pa_AbortStream is called. For a stream providing audio 953 or when Pa_StopStream or Pa_AbortStream is called. For a stream providing audio
878 output, if the stream callback returns paComplete, or Pa_StopStream is called, 954 output, if the stream callback returns paComplete, or Pa_StopStream() is called,
879 the stream finished callback will not be called until all generated sample data 955 the stream finished callback will not be called until all generated sample data
880 has been played. 956 has been played.
881 957
882 @param userData The userData parameter supplied to Pa_OpenStream() 958 @param userData The userData parameter supplied to Pa_OpenStream()
883 959
994 1070
995 1071
996 /** Retrieve a pointer to a PaStreamInfo structure containing information 1072 /** Retrieve a pointer to a PaStreamInfo structure containing information
997 about the specified stream. 1073 about the specified stream.
998 @return A pointer to an immutable PaStreamInfo structure. If the stream 1074 @return A pointer to an immutable PaStreamInfo structure. If the stream
999 parameter invalid, or an error is encountered, the function returns NULL. 1075 parameter is invalid, or an error is encountered, the function returns NULL.
1000 1076
1001 @param stream A pointer to an open stream previously created with Pa_OpenStream. 1077 @param stream A pointer to an open stream previously created with Pa_OpenStream.
1002 1078
1003 @note PortAudio manages the memory referenced by the returned pointer, 1079 @note PortAudio manages the memory referenced by the returned pointer,
1004 the client must not manipulate or free the memory. The pointer is only 1080 the client must not manipulate or free the memory. The pointer is only
1071 void *buffer, 1147 void *buffer,
1072 unsigned long frames ); 1148 unsigned long frames );
1073 1149
1074 1150
1075 /** Write samples to an output stream. This function doesn't return until the 1151 /** Write samples to an output stream. This function doesn't return until the
1076 entire buffer has been consumed - this may involve waiting for the operating 1152 entire buffer has been written - this may involve waiting for the operating
1077 system to consume the data. 1153 system to consume the data.
1078 1154
1079 @param stream A pointer to an open stream previously created with Pa_OpenStream. 1155 @param stream A pointer to an open stream previously created with Pa_OpenStream.
1080 1156
1081 @param buffer A pointer to a buffer of sample frames. The buffer contains 1157 @param buffer A pointer to a buffer of sample frames. The buffer contains