1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-01-10 22:55:56 +01:00

Update portaudio to upstream r1885

This commit is contained in:
lllucius
2013-02-27 01:33:15 +00:00
parent a8c69337c2
commit 123ec235c9
233 changed files with 36854 additions and 12370 deletions

View File

@@ -1,7 +1,7 @@
#ifndef PA_ASIO_H
#define PA_ASIO_H
/*
* $Id: pa_asio.h,v 1.9 2009-05-25 21:40:15 richardash1981 Exp $
* $Id: pa_asio.h 1667 2011-05-02 15:49:20Z rossb $
* PortAudio Portable Real-Time Audio Library
* ASIO specific extensions
*
@@ -44,7 +44,6 @@
@brief ASIO-specific PortAudio API extension header file.
*/
#include "portaudio.h"
#ifdef __cplusplus
@@ -53,24 +52,32 @@ extern "C"
#endif /* __cplusplus */
/** Retrieve legal latency settings for the specificed device, in samples.
/** Retrieve legal native buffer sizes for the specificed device, in sample frames.
@param device The global index of the device about which the query is being made.
@param minLatency A pointer to the location which will recieve the minimum latency value.
@param maxLatency A pointer to the location which will recieve the maximum latency value.
@param preferredLatency A pointer to the location which will recieve the preferred latency value.
@param granularity A pointer to the location which will recieve the granularity. This value
determines which values between minLatency and maxLatency are available. ie the step size,
if granularity is -1 then available latency settings are powers of two.
@param minBufferSizeFrames A pointer to the location which will receive the minimum buffer size value.
@param maxBufferSizeFrames A pointer to the location which will receive the maximum buffer size value.
@param preferredBufferSizeFrames A pointer to the location which will receive the preferred buffer size value.
@param granularity A pointer to the location which will receive the "granularity". This value determines
the step size used to compute the legal values between minBufferSizeFrames and maxBufferSizeFrames.
If granularity is -1 then available buffer size values are powers of two.
@see ASIOGetBufferSize in the ASIO SDK.
@todo This function should have a better name, any suggestions?
@note: this function used to be called PaAsio_GetAvailableLatencyValues. There is a
#define that maps PaAsio_GetAvailableLatencyValues to this function for backwards compatibility.
*/
PaError PaAsio_GetAvailableLatencyValues( PaDeviceIndex device,
long *minLatency, long *maxLatency, long *preferredLatency, long *granularity );
PaError PaAsio_GetAvailableBufferSizes( PaDeviceIndex device,
long *minBufferSizeFrames, long *maxBufferSizeFrames, long *preferredBufferSizeFrames, long *granularity );
/** Backwards compatibility alias for PaAsio_GetAvailableBufferSizes
@see PaAsio_GetAvailableBufferSizes
*/
#define PaAsio_GetAvailableLatencyValues PaAsio_GetAvailableBufferSizes
/** Display the ASIO control panel for the specified device.
@param device The global index of the device whose control panel is to be displayed.

View File

@@ -43,6 +43,7 @@
* @ingroup public_header
* @brief JACK-specific PortAudio API extension header file.
*/
#include "portaudio.h"
#ifdef __cplusplus

View File

@@ -2,7 +2,7 @@
#define PA_LINUX_ALSA_H
/*
* $Id: pa_linux_alsa.h,v 1.10 2009-05-25 21:40:16 richardash1981 Exp $
* $Id: pa_linux_alsa.h 1597 2011-02-11 00:15:51Z dmitrykos $
* PortAudio Portable Real-Time Audio Library
* ALSA-specific extensions
*
@@ -43,6 +43,7 @@
* @ingroup public_header
* @brief ALSA-specific PortAudio API extension header file.
*/
#include "portaudio.h"
#ifdef __cplusplus
@@ -92,6 +93,13 @@ PaError PaAlsa_SetNumPeriods( int numPeriods );
*/
PaError PaAlsa_SetRetriesBusy( int retries );
/** Set the path and name of ALSA library file if PortAudio is configured to load it dynamically (see
* PA_ALSA_DYNAMIC). This setting will overwrite the default name set by PA_ALSA_PATHNAME define.
* @param pathName Full path with filename. Only filename can be used, but dlopen() will lookup default
* searchable directories (/usr/lib;/usr/local/lib) then.
*/
void PaAlsa_SetLibraryPathName( const char *pathName );
#ifdef __cplusplus
}
#endif

View File

@@ -43,15 +43,17 @@
* @brief CoreAudio-specific PortAudio API extension header file.
*/
#include "portaudio.h"
#include <AudioUnit/AudioUnit.h>
//#include <AudioToolbox/AudioToolbox.h>
#include <AudioToolbox/AudioToolbox.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
/**
* A pointer to a paMacCoreStreamInfo may be passed as
* the hostApiSpecificStreamInfo in the PaStreamParameters struct
* when opening a stream or querying the format. Use NULL, for the
@@ -63,17 +65,17 @@ typedef struct
unsigned long size; /**size of whole structure including this header */
PaHostApiTypeId hostApiType; /**host API for which this data is intended */
unsigned long version; /**structure version */
unsigned long flags; /* flags to modify behaviour */
SInt32 const * channelMap; /* Channel map for HAL channel mapping , if not needed, use NULL;*/
unsigned long channelMapSize; /* Channel map size for HAL channel mapping , if not needed, use 0;*/
unsigned long flags; /** flags to modify behaviour */
SInt32 const * channelMap; /** Channel map for HAL channel mapping , if not needed, use NULL;*/
unsigned long channelMapSize; /** Channel map size for HAL channel mapping , if not needed, use 0;*/
} PaMacCoreStreamInfo;
/*
/**
* Functions
*/
/* Use this function to initialize a paMacCoreStreamInfo struct
/** Use this function to initialize a paMacCoreStreamInfo struct
* using the requested flags. Note that channel mapping is turned
* off after a call to this function.
* @param data The datastructure to initialize
@@ -81,14 +83,14 @@ typedef struct
*/
void PaMacCore_SetupStreamInfo( PaMacCoreStreamInfo *data, unsigned long flags );
/* call this after pa_SetupMacCoreStreamInfo to use channel mapping as described in notes.txt.
/** call this after pa_SetupMacCoreStreamInfo to use channel mapping as described in notes.txt.
* @param data The stream info structure to assign a channel mapping to
* @param channelMap The channel map array, as described in notes.txt. This array pointer will be used directly (ie the underlying data will not be copied), so the caller should not free the array until after the stream has been opened.
* @param channelMapSize The size of the channel map array.
*/
void PaMacCore_SetupChannelMap( PaMacCoreStreamInfo *data, const SInt32 * const channelMap, unsigned long channelMapSize );
/*
/**
* Retrieve the AudioDeviceID of the input device assigned to an open stream
*
* @param s The stream to query.
@@ -97,7 +99,7 @@ void PaMacCore_SetupChannelMap( PaMacCoreStreamInfo *data, const SInt32 * const
*/
AudioDeviceID PaMacCore_GetStreamInputDevice( PaStream* s );
/*
/**
* Retrieve the AudioDeviceID of the output device assigned to an open stream
*
* @param s The stream to query.
@@ -106,7 +108,7 @@ AudioDeviceID PaMacCore_GetStreamInputDevice( PaStream* s );
*/
AudioDeviceID PaMacCore_GetStreamOutputDevice( PaStream* s );
/*
/**
* Returns a statically allocated string with the device's name
* for the given channel. NULL will be returned on failure.
*
@@ -122,28 +124,41 @@ AudioDeviceID PaMacCore_GetStreamOutputDevice( PaStream* s );
*/
const char *PaMacCore_GetChannelName( int device, int channelIndex, bool input );
/*
/** Retrieve the range of legal native buffer sizes for the specificed device, in sample frames.
@param device The global index of the PortAudio device about which the query is being made.
@param minBufferSizeFrames A pointer to the location which will receive the minimum buffer size value.
@param maxBufferSizeFrames A pointer to the location which will receive the maximum buffer size value.
@see kAudioDevicePropertyBufferFrameSizeRange in the CoreAudio SDK.
*/
PaError PaMacCore_GetBufferSizeRange( PaDeviceIndex device,
long *minBufferSizeFrames, long *maxBufferSizeFrames );
/**
* Flags
*/
/*
/**
* The following flags alter the behaviour of PA on the mac platform.
* they can be ORed together. These should work both for opening and
* checking a device.
*/
/* Allows PortAudio to change things like the device's frame size,
/** Allows PortAudio to change things like the device's frame size,
* which allows for much lower latency, but might disrupt the device
* if other programs are using it, even when you are just Querying
* the device. */
#define paMacCoreChangeDeviceParameters (0x01)
/* In combination with the above flag,
/** In combination with the above flag,
* causes the stream opening to fail, unless the exact sample rates
* are supported by the device. */
#define paMacCoreFailIfConversionRequired (0x02)
/* These flags set the SR conversion quality, if required. The wierd ordering
/** These flags set the SR conversion quality, if required. The wierd ordering
* allows Maximum Quality to be the default.*/
#define paMacCoreConversionQualityMin (0x0100)
#define paMacCoreConversionQualityMedium (0x0200)
@@ -151,26 +166,26 @@ const char *PaMacCore_GetChannelName( int device, int channelIndex, bool input )
#define paMacCoreConversionQualityHigh (0x0400)
#define paMacCoreConversionQualityMax (0x0000)
/*
/**
* Here are some "preset" combinations of flags (above) to get to some
* common configurations. THIS IS OVERKILL, but if more flags are added
* it won't be.
*/
/*This is the default setting: do as much sample rate conversion as possible
/**This is the default setting: do as much sample rate conversion as possible
* and as little mucking with the device as possible. */
#define paMacCorePlayNice (0x00)
/*This setting is tuned for pro audio apps. It allows SR conversion on input
/**This setting is tuned for pro audio apps. It allows SR conversion on input
and output, but it tries to set the appropriate SR on the device.*/
#define paMacCorePro (0x01)
/*This is a setting to minimize CPU usage and still play nice.*/
/**This is a setting to minimize CPU usage and still play nice.*/
#define paMacCoreMinimizeCPUButPlayNice (0x0100)
/*This is a setting to minimize CPU usage, even if that means interrupting the device. */
/**This is a setting to minimize CPU usage, even if that means interrupting the device. */
#define paMacCoreMinimizeCPU (0x0101)
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /** __cplusplus */
#endif /* PA_MAC_CORE_H */
#endif /** PA_MAC_CORE_H */

View File

@@ -1,7 +1,7 @@
#ifndef PA_WIN_DS_H
#define PA_WIN_DS_H
/*
* $Id: pa_win_ds.h,v 1.8 2009-01-01 22:31:28 martynshaw Exp $
* $Id: $
* PortAudio Portable Real-Time Audio Library
* DirectSound specific extensions
*
@@ -28,13 +28,13 @@
*/
/*
* The text above constitutes the entire PortAudio license; however,
* The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
* they can be incorporated into the canonical version. It is also
* requested that these non-binding requests be included along with the
* they can be incorporated into the canonical version. It is also
* requested that these non-binding requests be included along with the
* license above.
*/
@@ -43,7 +43,6 @@
@brief DirectSound-specific PortAudio API extension header file.
*/
#include "portaudio.h"
#include "pa_win_waveformat.h"
@@ -60,30 +59,25 @@ extern "C"
typedef struct PaWinDirectSoundStreamInfo{
unsigned long size; /**< sizeof(PaWinDirectSoundStreamInfo) */
PaHostApiTypeId hostApiType; /**< paDirectSound */
unsigned long version; /**< 1 */
unsigned long version; /**< 2 */
unsigned long flags;
unsigned long flags; /**< enable other features of this struct */
/* low-level latency setting support
TODO ** NOT IMPLEMENTED **
These settings control the number and size of host buffers in order
to set latency. They will be used instead of the generic parameters
to Pa_OpenStream() if flags contains the paWinDirectSoundUseLowLevelLatencyParameters
flag.
/**
low-level latency setting support
Sets the size of the DirectSound host buffer.
When flags contains the paWinDirectSoundUseLowLevelLatencyParameters
this size will be used instead of interpreting the generic latency
parameters to Pa_OpenStream(). If the flag is not set this value is ignored.
If PaWinDirectSoundStreamInfo structures with paWinDirectSoundUseLowLevelLatencyParameters
are supplied for both input and output in a full duplex stream, then the
input and output framesPerBuffer must be the same, or the larger of the
two must be a multiple of the smaller, otherwise a
paIncompatibleHostApiSpecificStreamInfo error will be returned from
Pa_OpenStream().
unsigned long framesPerBuffer;
If the stream is a full duplex stream the implementation requires that
the values of framesPerBuffer for input and output match (if both are specified).
*/
unsigned long framesPerBuffer;
/*
/**
support for WAVEFORMATEXTENSIBLE channel masks. If flags contains
paWinDirectSoundUseChannelMask this allows you to specify which speakers
paWinDirectSoundUseChannelMask this allows you to specify which speakers
to address in a multichannel stream. Constants for channelMask
are specified in pa_win_waveformat.h
@@ -92,25 +86,10 @@ typedef struct PaWinDirectSoundStreamInfo{
}PaWinDirectSoundStreamInfo;
/** Retrieve the GUID of the input device.
@param stream The stream to query.
@return A pointer to the GUID, or NULL if none.
*/
LPGUID PaWinDS_GetStreamInputGUID( PaStream* s );
/** Retrieve the GUID of the output device.
@param stream The stream to query.
@return A pointer to the GUID, or NULL if none.
*/
LPGUID PaWinDS_GetStreamOutputGUID( PaStream* s );
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* PA_WIN_DS_H */
#endif /* PA_WIN_DS_H */

View File

@@ -29,13 +29,13 @@
*/
/*
* The text above constitutes the entire PortAudio license; however,
* The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
* they can be incorporated into the canonical version. It is also
* requested that these non-binding requests be included along with the
* they can be incorporated into the canonical version. It is also
* requested that these non-binding requests be included along with the
* license above.
*/
@@ -125,11 +125,11 @@ typedef unsigned long PaWinWaveFormatChannelMask;
/*
PaWinWaveFormat is defined here to provide compatibility with
compilation environments which don't have headers defining
compilation environments which don't have headers defining
WAVEFORMATEXTENSIBLE (e.g. older versions of MSVC, Borland C++ etc.
The fields for WAVEFORMATEX and WAVEFORMATEXTENSIBLE are declared as an
unsigned char array here to avoid clients who include this file having
unsigned char array here to avoid clients who include this file having
a dependency on windows.h and mmsystem.h, and also to to avoid having
to write separate packing pragmas for each compiler.
*/
@@ -138,18 +138,18 @@ typedef unsigned long PaWinWaveFormatChannelMask;
typedef struct{
unsigned char fields[ PAWIN_SIZEOF_WAVEFORMATEXTENSIBLE ];
unsigned long extraLongForAlignment; /* ensure that compiler aligns struct to DWORD */
unsigned long extraLongForAlignment; /* ensure that compiler aligns struct to DWORD */
} PaWinWaveFormat;
/*
WAVEFORMATEXTENSIBLE fields:
union {
WORD wValidBitsPerSample;
WORD wSamplesPerBlock;
WORD wReserved;
WORD wValidBitsPerSample;
WORD wSamplesPerBlock;
WORD wReserved;
} Samples;
DWORD dwChannelMask;
DWORD dwChannelMask;
GUID SubFormat;
*/
@@ -157,6 +157,7 @@ typedef struct{
#define PAWIN_INDEXOF_DWCHANNELMASK (PAWIN_SIZEOF_WAVEFORMATEX+2)
#define PAWIN_INDEXOF_SUBFORMAT (PAWIN_SIZEOF_WAVEFORMATEX+6)
/*
Valid values to pass for the waveFormatTag PaWin_InitializeWaveFormatEx and
PaWin_InitializeWaveFormatExtensible functions below. These must match
@@ -178,11 +179,11 @@ int PaWin_SampleFormatToLinearWaveFormatTag( PaSampleFormat sampleFormat );
Use the following two functions to initialize the waveformat structure.
*/
void PaWin_InitializeWaveFormatEx( PaWinWaveFormat *waveFormat,
void PaWin_InitializeWaveFormatEx( PaWinWaveFormat *waveFormat,
int numChannels, PaSampleFormat sampleFormat, int waveFormatTag, double sampleRate );
void PaWin_InitializeWaveFormatExtensible( PaWinWaveFormat *waveFormat,
void PaWin_InitializeWaveFormatExtensible( PaWinWaveFormat *waveFormat,
int numChannels, PaSampleFormat sampleFormat, int waveFormatTag, double sampleRate,
PaWinWaveFormatChannelMask channelMask );
@@ -195,4 +196,4 @@ PaWinWaveFormatChannelMask PaWin_DefaultChannelMask( int numChannels );
}
#endif /* __cplusplus */
#endif /* PA_WIN_WAVEFORMAT_H */
#endif /* PA_WIN_WAVEFORMAT_H */

View File

@@ -0,0 +1,106 @@
#ifndef PA_WIN_WDMKS_H
#define PA_WIN_WDMKS_H
/*
* $Id: pa_win_wdmks.h 1812 2012-02-14 09:32:57Z robiwan $
* PortAudio Portable Real-Time Audio Library
* WDM/KS specific extensions
*
* Copyright (c) 1999-2007 Ross Bencina and Phil Burk
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/*
* The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
* they can be incorporated into the canonical version. It is also
* requested that these non-binding requests be included along with the
* license above.
*/
/** @file
@ingroup public_header
@brief WDM Kernel Streaming-specific PortAudio API extension header file.
*/
#include "portaudio.h"
#include <windows.h>
#ifdef __cplusplus
extern "C"
{
#endif /* __cplusplus */
typedef struct PaWinWDMKSInfo{
unsigned long size; /**< sizeof(PaWinWDMKSInfo) */
PaHostApiTypeId hostApiType; /**< paWDMKS */
unsigned long version; /**< 1 */
/* The number of packets to use for WaveCyclic devices, range is [2, 8]. Set to zero for default value of 2. */
unsigned noOfPackets;
} PaWinWDMKSInfo;
typedef enum PaWDMKSType
{
Type_kNotUsed,
Type_kWaveCyclic,
Type_kWaveRT,
Type_kCnt,
} PaWDMKSType;
typedef enum PaWDMKSSubType
{
SubType_kUnknown,
SubType_kNotification,
SubType_kPolled,
SubType_kCnt,
} PaWDMKSSubType;
typedef struct PaWinWDMKSDeviceInfo {
wchar_t filterPath[MAX_PATH]; /**< KS filter path in Unicode! */
wchar_t topologyPath[MAX_PATH]; /**< Topology filter path in Unicode! */
PaWDMKSType streamingType;
GUID deviceProductGuid; /**< The product GUID of the device (if supported) */
} PaWinWDMKSDeviceInfo;
typedef struct PaWDMKSDirectionSpecificStreamInfo
{
PaDeviceIndex device;
unsigned channels; /**< No of channels the device is opened with */
unsigned framesPerHostBuffer; /**< No of frames of the device buffer */
int endpointPinId; /**< Endpoint pin ID (on topology filter if topologyName is not empty) */
int muxNodeId; /**< Only valid for input */
PaWDMKSSubType streamingSubType; /**< Not known until device is opened for streaming */
} PaWDMKSDirectionSpecificStreamInfo;
typedef struct PaWDMKSSpecificStreamInfo {
PaWDMKSDirectionSpecificStreamInfo input;
PaWDMKSDirectionSpecificStreamInfo output;
} PaWDMKSSpecificStreamInfo;
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* PA_WIN_DS_H */

View File

@@ -1,7 +1,7 @@
#ifndef PA_WIN_WMME_H
#define PA_WIN_WMME_H
/*
* $Id: pa_win_wmme.h,v 1.9 2009-05-25 21:40:16 richardash1981 Exp $
* $Id: pa_win_wmme.h 1592 2011-02-04 10:41:58Z rossb $
* PortAudio Portable Real-Time Audio Library
* MME specific extensions
*
@@ -43,7 +43,6 @@
@brief WMME-specific PortAudio API extension header file.
*/
#include "portaudio.h"
#include "pa_win_waveformat.h"

View File

@@ -1,7 +1,7 @@
#ifndef PORTAUDIO_H
#define PORTAUDIO_H
/*
* $Id: portaudio.h 1542 2010-10-14 03:34:34Z rossb $
* $Id: portaudio.h 1859 2012-09-01 00:10:13Z philburk $
* PortAudio Portable Real-Time Audio Library
* PortAudio API Header File
* Latest version available at: http://www.portaudio.com/
@@ -95,10 +95,10 @@ typedef enum PaErrorCode
paOutputUnderflowed,
paHostApiNotFound,
paInvalidHostApi,
paCanNotReadFromACallbackStream, /**< @todo review error code name */
paCanNotWriteToACallbackStream, /**< @todo review error code name */
paCanNotReadFromAnOutputOnlyStream, /**< @todo review error code name */
paCanNotWriteToAnInputOnlyStream, /**< @todo review error code name */
paCanNotReadFromACallbackStream,
paCanNotWriteToACallbackStream,
paCanNotReadFromAnOutputOnlyStream,
paCanNotWriteToAnInputOnlyStream,
paIncompatibleStreamHostApi,
paBadBufferPtr
} PaErrorCode;
@@ -111,7 +111,7 @@ const char *Pa_GetErrorText( PaError errorCode );
/** Library initialization function - call this before using PortAudio.
This function initialises internal data structures and prepares underlying
This function initializes internal data structures and prepares underlying
host APIs for use. With the exception of Pa_GetVersion(), Pa_GetVersionText(),
and Pa_GetErrorText(), this function MUST be called before using any other
PortAudio API functions.
@@ -134,7 +134,7 @@ PaError Pa_Initialize( void );
/** Library termination function - call this when finished using PortAudio.
This function deallocates all resources allocated by PortAudio since it was
initializied by a call to Pa_Initialize(). In cases where Pa_Initialise() has
initialized by a call to Pa_Initialize(). In cases where Pa_Initialise() has
been called multiple times, each call must be matched with a corresponding call
to Pa_Terminate(). The final matching call to Pa_Terminate() will automatically
close any PortAudio streams that are still open.
@@ -344,13 +344,13 @@ typedef struct PaHostErrorInfo{
/** Return information about the last host error encountered. The error
information returned by Pa_GetLastHostErrorInfo() will never be modified
asyncronously by errors occurring in other PortAudio owned threads
asynchronously by errors occurring in other PortAudio owned threads
(such as the thread that manages the stream callback.)
This function is provided as a last resort, primarily to enhance debugging
by providing clients with access to all available error information.
@return A pointer to an immutable structure constaining information about
@return A pointer to an immutable structure constraining information about
the host error. The values in this structure will only be valid if a
PortAudio function has previously returned the paUnanticipatedHostError
error code.
@@ -383,7 +383,7 @@ PaDeviceIndex Pa_GetDefaultInputDevice( void );
/** Retrieve the index of the default output device. The result can be
used in the outputDevice parameter to Pa_OpenStream().
@return The default output device index for the defualt host API, or paNoDevice
@return The default output device index for the default host API, or paNoDevice
if no default output device is available or an error was encountered.
@note
@@ -398,11 +398,13 @@ PaDeviceIndex Pa_GetDefaultInputDevice( void );
PaDeviceIndex Pa_GetDefaultOutputDevice( void );
/** The type used to represent monotonic time in seconds that can be used
for syncronisation. The type is used for the outTime argument to the
/** The type used to represent monotonic time in seconds. PaTime is
used for the fields of the PaStreamCallbackTimeInfo argument to the
PaStreamCallback and as the result of Pa_GetStreamTime().
PaTime values have unspecified origin.
@see PaStreamCallback, Pa_GetStreamTime
@see PaStreamCallback, PaStreamCallbackTimeInfo, Pa_GetStreamTime
*/
typedef double PaTime;
@@ -448,15 +450,15 @@ typedef struct PaDeviceInfo
{
int structVersion; /* this is struct version 2 */
const char *name;
PaHostApiIndex hostApi; /* note this is a host API index, not a type id*/
PaHostApiIndex hostApi; /**< note this is a host API index, not a type id*/
int maxInputChannels;
int maxOutputChannels;
/* Default latency values for interactive performance. */
/** Default latency values for interactive performance. */
PaTime defaultLowInputLatency;
PaTime defaultLowOutputLatency;
/* Default latency values for robust non-interactive applications (eg. playing sound files). */
/** Default latency values for robust non-interactive applications (eg. playing sound files). */
PaTime defaultHighInputLatency;
PaTime defaultHighOutputLatency;
@@ -509,8 +511,8 @@ typedef struct PaStreamParameters
configure their latency based on these parameters, otherwise they may
choose the closest viable latency instead. Unless the suggested latency
is greater than the absolute upper limit for the device implementations
should round the suggestedLatency up to the next practial value - ie to
provide an equal or higher latency than suggestedLatency wherever possibe.
should round the suggestedLatency up to the next practical value - ie to
provide an equal or higher latency than suggestedLatency wherever possible.
Actual latency values for an open stream may be retrieved using the
inputLatency and outputLatency fields of the PaStreamInfo structure
returned by Pa_GetStreamInfo().
@@ -638,11 +640,15 @@ typedef unsigned long PaStreamFlags;
/**
Timing information for the buffers passed to the stream callback.
Time values are expressed in seconds and are synchronised with the time base used by Pa_GetStreamTime() for the associated stream.
@see PaStreamCallback, Pa_GetStreamTime
*/
typedef struct PaStreamCallbackTimeInfo{
PaTime inputBufferAdcTime;
PaTime currentTime;
PaTime outputBufferDacTime;
PaTime inputBufferAdcTime; /**< The time when the first sample of the input buffer was captured at the ADC input */
PaTime currentTime; /**< The time when the stream callback was invoked */
PaTime outputBufferDacTime; /**< The time when the first sample of the output buffer will output the DAC */
} PaStreamCallbackTimeInfo;
@@ -695,9 +701,9 @@ typedef unsigned long PaStreamCallbackFlags;
*/
typedef enum PaStreamCallbackResult
{
paContinue=0,
paComplete=1,
paAbort=2
paContinue=0, /**< Signal that the stream should continue invoking the callback and processing audio. */
paComplete=1, /**< Signal that the stream should stop invoking the callback and finish once all output samples have played. */
paAbort=2 /**< Signal that the stream should stop invoking the callback and finish as soon as possible. */
} PaStreamCallbackResult;
@@ -705,6 +711,28 @@ typedef enum PaStreamCallbackResult
Functions of type PaStreamCallback are implemented by PortAudio clients.
They consume, process or generate audio in response to requests from an
active PortAudio stream.
When a stream is running, PortAudio calls the stream callback periodically.
The callback function is responsible for processing buffers of audio samples
passed via the input and output parameters.
The PortAudio stream callback runs at very high or real-time priority.
It is required to consistently meet its time deadlines. Do not allocate
memory, access the file system, call library functions or call other functions
from the stream callback that may block or take an unpredictable amount of
time to complete.
In order for a stream to maintain glitch-free operation the callback
must consume and return audio data faster than it is recorded and/or
played. PortAudio anticipates that each callback invocation may execute for
a duration approaching the duration of frameCount audio frames at the stream
sample rate. It is reasonable to expect to be able to utilise 70% or more of
the available CPU time in the PortAudio callback. However, due to buffer size
adaption and other factors, not all host APIs are able to guarantee audio
stability under heavy CPU load with arbitrary fixed callback buffer sizes.
When high callback CPU utilisation is required the most robust behavior
can be achieved by using paFramesPerBufferUnspecified as the
Pa_OpenStream() framesPerBuffer parameter.
@param input and @param output are either arrays of interleaved samples or;
if non-interleaved samples were requested using the paNonInterleaved sample
@@ -717,11 +745,10 @@ typedef enum PaStreamCallbackResult
@param frameCount The number of sample frames to be processed by
the stream callback.
@param timeInfo The time in seconds when the first sample of the input
buffer was received at the audio input, the time in seconds when the first
sample of the output buffer will begin being played at the audio output, and
the time in seconds when the stream callback was called.
See also Pa_GetStreamTime()
@param timeInfo Timestamps indicating the ADC capture time of the first sample
in the input buffer, the DAC output time of the first sample in the output buffer
and the time the callback was invoked.
See PaStreamCallbackTimeInfo and Pa_GetStreamTime()
@param statusFlags Flags indicating whether input and/or output buffers
have been inserted or will be dropped to overcome underflow or overflow
@@ -732,21 +759,21 @@ typedef enum PaStreamCallbackResult
@return
The stream callback should return one of the values in the
PaStreamCallbackResult enumeration. To ensure that the callback continues
::PaStreamCallbackResult enumeration. To ensure that the callback continues
to be called, it should return paContinue (0). Either paComplete or paAbort
can be returned to finish stream processing, after either of these values is
returned the callback will not be called again. If paAbort is returned the
stream will finish as soon as possible. If paComplete is returned, the stream
will continue until all buffers generated by the callback have been played.
This may be useful in applications such as soundfile players where a specific
duration of output is required. However, it is not necessary to utilise this
duration of output is required. However, it is not necessary to utilize this
mechanism as Pa_StopStream(), Pa_AbortStream() or Pa_CloseStream() can also
be used to stop the stream. The callback must always fill the entire output
buffer irrespective of its return value.
@see Pa_OpenStream, Pa_OpenDefaultStream
@note With the exception of Pa_GetStreamCpuLoad() it is not permissable to call
@note With the exception of Pa_GetStreamCpuLoad() it is not permissible to call
PortAudio API functions from within the stream callback.
*/
typedef int PaStreamCallback(
@@ -776,7 +803,7 @@ typedef int PaStreamCallback(
@param framesPerBuffer The number of frames passed to the stream callback
function, or the preferred block granularity for a blocking read/write stream.
The special value paFramesPerBufferUnspecified (0) may be used to request that
the stream callback will recieve an optimal (and possibly varying) number of
the stream callback will receive an optimal (and possibly varying) number of
frames based on host requirements and the requested latency settings.
Note: With some host APIs, the use of non-zero framesPerBuffer for a callback
stream may introduce an additional layer of buffering which could introduce
@@ -785,7 +812,7 @@ typedef int PaStreamCallback(
that a non-zero framesPerBuffer value only be used when your algorithm
requires a fixed number of frames per stream callback.
@param streamFlags Flags which modify the behaviour of the streaming process.
@param streamFlags Flags which modify the behavior of the streaming process.
This parameter may contain a combination of flags ORed together. Some flags may
only be relevant to certain buffer formats.
@@ -834,7 +861,7 @@ PaError Pa_OpenStream( PaStream** stream,
@param numOutputChannels The number of channels of sound to be delivered to the
stream callback or passed to Pa_WriteStream. It can range from 1 to the value
of maxOutputChannels in the PaDeviceInfo record for the default output dvice.
of maxOutputChannels in the PaDeviceInfo record for the default output device.
If 0 the stream is opened as an output-only stream.
@param sampleFormat The sample format of both the input and output buffers
@@ -994,7 +1021,7 @@ typedef struct PaStreamInfo
/** Retrieve a pointer to a PaStreamInfo structure containing information
about the specified stream.
@return A pointer to an immutable PaStreamInfo structure. If the stream
parameter invalid, or an error is encountered, the function returns NULL.
parameter is invalid, or an error is encountered, the function returns NULL.
@param stream A pointer to an open stream previously created with Pa_OpenStream.
@@ -1007,13 +1034,20 @@ typedef struct PaStreamInfo
const PaStreamInfo* Pa_GetStreamInfo( PaStream *stream );
/** Determine the current time for the stream according to the same clock used
to generate buffer timestamps. This time may be used for syncronising other
events to the audio stream, for example synchronizing audio to MIDI.
/** Returns the current time in seconds for a stream according to the same clock used
to generate callback PaStreamCallbackTimeInfo timestamps. The time values are
monotonically increasing and have unspecified origin.
Pa_GetStreamTime returns valid time values for the entire life of the stream,
from when the stream is opened until it is closed. Starting and stopping the stream
does not affect the passage of time returned by Pa_GetStreamTime.
This time may be used for synchronizing other events to the audio stream, for
example synchronizing audio to MIDI.
@return The stream's current time in seconds, or 0 if an error occurred.
@see PaTime, PaStreamCallback
@see PaTime, PaStreamCallback, PaStreamCallbackTimeInfo
*/
PaTime Pa_GetStreamTime( PaStream *stream );
@@ -1032,7 +1066,7 @@ PaTime Pa_GetStreamTime( PaStream *stream );
to maintain real-time operation. A value of 0.5 would imply that PortAudio and
the stream callback was consuming roughly 50% of the available CPU time. The
return value may exceed 1.0. A value of 0.0 will always be returned for a
blocking read/write stream, or if an error occurrs.
blocking read/write stream, or if an error occurs.
*/
double Pa_GetStreamCpuLoad( PaStream* stream );
@@ -1112,15 +1146,6 @@ signed long Pa_GetStreamReadAvailable( PaStream* stream );
signed long Pa_GetStreamWriteAvailable( PaStream* stream );
/** Retrieve the host type handling an open stream.
@return Returns a non-negative value representing the host API type
handling an open stream or, a PaErrorCode (which are always negative)
if PortAudio is not initialized or an error is encountered.
*/
PaHostApiTypeId Pa_GetStreamHostApiType( PaStream* stream );
/* Miscellaneous utilities */