PortAudio
2.0
|
WASAPI-specific PortAudio API extension header file. More...
Go to the source code of this file.
Data Structures | |
struct | PaWasapiJackDescription |
struct | PaWasapiStreamInfo |
Macros | |
#define | paWinWasapiExclusive (paWinWasapiExclusive) |
#define | paWinWasapiRedirectHostProcessor (paWinWasapiRedirectHostProcessor) |
#define | paWinWasapiUseChannelMask (paWinWasapiUseChannelMask) |
#define | paWinWasapiPolling (paWinWasapiPolling) |
#define | paWinWasapiThreadPriority (paWinWasapiThreadPriority) |
#define | paWinWasapiExplicitSampleFormat (paWinWasapiExplicitSampleFormat) |
#define | paWinWasapiAutoConvert (paWinWasapiAutoConvert) |
#define | paWasapiStreamStateError (paWasapiStreamStateError) |
#define | paWasapiStreamStateThreadPrepare (paWasapiStreamStateThreadPrepare) |
#define | paWasapiStreamStateThreadStart (paWasapiStreamStateThreadStart) |
#define | paWasapiStreamStateThreadStop (paWasapiStreamStateThreadStop) |
Typedefs | |
typedef enum PaWasapiFlags | PaWasapiFlags |
typedef enum PaWasapiStreamState | PaWasapiStreamState |
typedef void(* | PaWasapiHostProcessorCallback )(void *inputBuffer, long inputFrames, void *outputBuffer, long outputFrames, void *userData) |
typedef void(* | PaWasapiStreamStateCallback )(PaStream *pStream, unsigned int stateFlags, unsigned int errorId, void *pUserData) |
typedef enum PaWasapiDeviceRole | PaWasapiDeviceRole |
typedef enum PaWasapiJackConnectionType | PaWasapiJackConnectionType |
typedef enum PaWasapiJackGeoLocation | PaWasapiJackGeoLocation |
typedef enum PaWasapiJackGenLocation | PaWasapiJackGenLocation |
typedef enum PaWasapiJackPortConnection | PaWasapiJackPortConnection |
typedef enum PaWasapiThreadPriority | PaWasapiThreadPriority |
typedef struct PaWasapiJackDescription | PaWasapiJackDescription |
typedef enum PaWasapiStreamCategory | PaWasapiStreamCategory |
typedef enum PaWasapiStreamOption | PaWasapiStreamOption |
typedef struct PaWasapiStreamInfo | PaWasapiStreamInfo |
WASAPI-specific PortAudio API extension header file.
#define paWasapiStreamStateError (paWasapiStreamStateError) |
#define paWasapiStreamStateThreadPrepare (paWasapiStreamStateThreadPrepare) |
#define paWasapiStreamStateThreadStart (paWasapiStreamStateThreadStart) |
#define paWasapiStreamStateThreadStop (paWasapiStreamStateThreadStop) |
#define paWinWasapiAutoConvert (paWinWasapiAutoConvert) |
#define paWinWasapiExclusive (paWinWasapiExclusive) |
#define paWinWasapiExplicitSampleFormat (paWinWasapiExplicitSampleFormat) |
#define paWinWasapiPolling (paWinWasapiPolling) |
#define paWinWasapiRedirectHostProcessor (paWinWasapiRedirectHostProcessor) |
#define paWinWasapiThreadPriority (paWinWasapiThreadPriority) |
#define paWinWasapiUseChannelMask (paWinWasapiUseChannelMask) |
typedef enum PaWasapiDeviceRole PaWasapiDeviceRole |
typedef enum PaWasapiFlags PaWasapiFlags |
typedef void(* PaWasapiHostProcessorCallback)(void *inputBuffer, long inputFrames, void *outputBuffer, long outputFrames, void *userData) |
typedef enum PaWasapiJackConnectionType PaWasapiJackConnectionType |
typedef struct PaWasapiJackDescription PaWasapiJackDescription |
typedef enum PaWasapiJackGenLocation PaWasapiJackGenLocation |
typedef enum PaWasapiJackGeoLocation PaWasapiJackGeoLocation |
typedef enum PaWasapiJackPortConnection PaWasapiJackPortConnection |
typedef enum PaWasapiStreamCategory PaWasapiStreamCategory |
Stream category. Note:
typedef struct PaWasapiStreamInfo PaWasapiStreamInfo |
typedef enum PaWasapiStreamOption PaWasapiStreamOption |
Stream option. Note:
typedef enum PaWasapiStreamState PaWasapiStreamState |
typedef void(* PaWasapiStreamStateCallback)(PaStream *pStream, unsigned int stateFlags, unsigned int errorId, void *pUserData) |
typedef enum PaWasapiThreadPriority PaWasapiThreadPriority |
enum PaWasapiDeviceRole |
enum PaWasapiFlags |
Stream category. Note:
enum PaWasapiStreamOption |
Stream option. Note:
enum PaWasapiStreamState |
Returns pointer to WASAPI's IAudioClient object of the stream.
pStream | Pointer to PaStream object. |
pAudioClient | Pointer to pointer of IAudioClient. |
bOutput | TRUE (1) for output stream, FALSE (0) for input stream. |
References PaWasapiSubStream::clientParent, PaWasapiStream::in, PaWasapiStream::out, paBadStreamPtr, paNoError, paUnanticipatedHostError, and TRUE.
int PaWasapi_GetDeviceCurrentFormat | ( | PaStream * | pStream, |
void * | pFormat, | ||
unsigned int | formatSize, | ||
int | bOutput | ||
) |
Get current audio format of the device assigned to the opened stream.
Format is represented by PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure. Use this function to reconfirm format if PA's processor is overriden and paWinWasapiRedirectHostProcessor flag is specified.
pStream | Pointer to PaStream object. |
pFormat | Pointer to PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure. |
formatSize | Size of PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure in bytes. |
bOutput | TRUE (1) for output stream, FALSE (0) for input stream. |
References PaWasapiStream::in, PaWasapiStream::out, paBadStreamPtr, TRUE, and PaWasapiSubStream::wavex.
int PaWasapi_GetDeviceDefaultFormat | ( | void * | pFormat, |
unsigned int | formatSize, | ||
PaDeviceIndex | device | ||
) |
Get default audio format for the device in Shared Mode.
Format is represented by PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure and obtained by getting the device property with a PKEY_AudioEngine_DeviceFormat key.
pFormat | Pointer to PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure. |
formatSize | Size of PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure in bytes. |
device | Device index. |
References PaWasapiDeviceInfo::DefaultFormat, PaWasapiHostApiRepresentation::deviceCount, PaWasapiHostApiRepresentation::devInfo, PaWasapiHostApiRepresentation::inheritedHostApiRep, paBadBufferPtr, paBufferTooSmall, paInvalidDevice, paNoError, and PaUtil_DeviceIndexToHostApiDeviceIndex().
int PaWasapi_GetDeviceMixFormat | ( | void * | pFormat, |
unsigned int | formatSize, | ||
PaDeviceIndex | device | ||
) |
Get mix audio format for the device in Shared Mode.
Format is represented by PaWinWaveFormat or WAVEFORMATEXTENSIBLE structureand obtained by IAudioClient::GetMixFormat.
pFormat | Pointer to PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure. |
formatSize | Size of PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure in bytes. |
device | Device index. |
References PaWasapiHostApiRepresentation::deviceCount, PaWasapiHostApiRepresentation::devInfo, PaWasapiHostApiRepresentation::inheritedHostApiRep, PaWasapiDeviceInfo::MixFormat, paBadBufferPtr, paBufferTooSmall, paInvalidDevice, paNoError, and PaUtil_DeviceIndexToHostApiDeviceIndex().
int PaWasapi_GetDeviceRole | ( | PaDeviceIndex | device | ) |
Get device role (PaWasapiDeviceRole enum).
device | Device index. |
References PaWasapiHostApiRepresentation::deviceCount, PaWasapiHostApiRepresentation::devInfo, PaWasapiDeviceInfo::formFactor, PaWasapiHostApiRepresentation::inheritedHostApiRep, paInvalidDevice, paNoError, paNotInitialized, and PaUtil_DeviceIndexToHostApiDeviceIndex().
PaError PaWasapi_GetFramesPerHostBuffer | ( | PaStream * | pStream, |
unsigned int * | pInput, | ||
unsigned int * | pOutput | ||
) |
Get number of frames per host buffer.
It is max value of frames of WASAPI buffer which can be locked for operations. Use this method as helper to findout max values of inputFrames/outputFrames of PaWasapiHostProcessorCallback.
pStream | Pointer to PaStream object. |
pInput | Pointer to variable to receive number of input frames. Can be NULL. |
pOutput | Pointer to variable to receive number of output frames. Can be NULL. |
References PaWasapiSubStream::framesPerHostCallback, PaWasapiStream::in, PaWasapiStream::out, paBadStreamPtr, and paNoError.
PaError PaWasapi_GetJackCount | ( | PaDeviceIndex | device, |
int * | pJackCount | ||
) |
Get number of jacks associated with a WASAPI device.
Use this method to determine if there are any jacks associated with the provided WASAPI device. Not all audio devices will support this capability. This is valid for both input and output devices.
device | Device index. |
pJackCount | Pointer to variable to receive number of jacks. |
References PaWasapiDeviceInfo::device, PaWasapiHostApiRepresentation::deviceCount, PaWasapiHostApiRepresentation::devInfo, IF_FAILED_JUMP, PaWasapiHostApiRepresentation::inheritedHostApiRep, LogHostError, paInvalidDevice, paNoError, paNotInitialized, paUnanticipatedHostError, PaUtil_DeviceIndexToHostApiDeviceIndex(), and SAFE_RELEASE.
PaError PaWasapi_GetJackDescription | ( | PaDeviceIndex | device, |
int | jackIndex, | ||
PaWasapiJackDescription * | pJackDescription | ||
) |
Get the jack description associated with a WASAPI device and jack number.
Before this function is called, use PaWasapi_GetJackCount to determine the number of jacks associated with device. If jcount is greater than zero, then each jack from 0 to jcount can be queried with this function to get the jack description.
device | Device index. |
jackIndex | Jack index. |
pJackDescription | Pointer to PaWasapiJackDescription. |
References PaWasapiJackDescription::channelMapping, PaWasapiJackDescription::color, PaWasapiJackDescription::connectionType, PaWasapiDeviceInfo::device, PaWasapiHostApiRepresentation::deviceCount, PaWasapiHostApiRepresentation::devInfo, PaWasapiJackDescription::genLocation, PaWasapiJackDescription::geoLocation, IF_FAILED_JUMP, PaWasapiHostApiRepresentation::inheritedHostApiRep, PaWasapiJackDescription::isConnected, LogHostError, paInvalidDevice, paNoError, paNotInitialized, paUnanticipatedHostError, PaUtil_DeviceIndexToHostApiDeviceIndex(), PaWasapiJackDescription::portConnection, and SAFE_RELEASE.
PaError PaWasapi_SetStreamStateHandler | ( | PaStream * | pStream, |
PaWasapiStreamStateCallback | fnStateHandler, | ||
void * | pUserData | ||
) |
Set stream state handler.
pStream | Pointer to PaStream object. |
fnStateHandler | Pointer to state handling function. |
pUserData | Pointer to user data. |
References PaWasapiStream::fnStateHandler, paBadStreamPtr, paNoError, and PaWasapiStream::pStateHandlerUserData.
PaError PaWasapi_ThreadPriorityBoost | ( | void ** | pTask, |
PaWasapiThreadPriority | priorityClass | ||
) |
Boost thread priority of calling thread (MMCSS).
Use it for Blocking Interface only inside the thread which makes calls to Pa_WriteStream/Pa_ReadStream.
pTask | Handle to pointer to priority task. Must be used with PaWasapi_RevertThreadPriority method to revert thread priority to initial state. |
priorityClass | Id of thread priority of PaWasapiThreadPriority type. Specifying eThreadPriorityNone does nothing. |
References eThreadPriorityAudio, eThreadPriorityProAudio, FALSE, HANDLE(), paNoError, and paUnanticipatedHostError.
Referenced by ProcThreadEvent(), and ProcThreadPoll().
PaError PaWasapi_ThreadPriorityRevert | ( | void * | pTask | ) |
Boost thread priority of calling thread (MMCSS).
Use it for Blocking Interface only inside the thread which makes calls to Pa_WriteStream/Pa_ReadStream.
pTask | Task handle obtained by PaWasapi_BoostThreadPriority method. |
References FALSE, paNoError, and paUnanticipatedHostError.
PaError PaWasapi_UpdateDeviceList | ( | ) |
Update device list.
This function is available if PA_WASAPI_MAX_CONST_DEVICE_COUNT is defined during compile time with maximum constant WASAPI device count (recommended value - 32). If PA_WASAPI_MAX_CONST_DEVICE_COUNT is set to 0 (or not defined) during compile time the implementation will not define PaWasapi_UpdateDeviceList() and thus updating device list can only be possible by calling Pa_Terminate() and then Pa_Initialize().
PaError PaWasapiWinrt_PopulateDeviceList | ( | const unsigned short ** | pId, |
const unsigned short ** | pName, | ||
const PaWasapiDeviceRole * | pRole, | ||
unsigned int | count, | ||
int | bOutput | ||
) |
Populate the device list.
By default the implementation will rely on DEVINTERFACE_AUDIO_RENDER and DEVINTERFACE_AUDIO_CAPTURE as default devices. If device Id is provided by PaWasapiWinrt_SetDefaultDeviceId() then those device Ids will be used as default and only devices for the device list.
By populating the device list you can provide an additional available audio devices of the system to PA which are obtainable by: Windows::Devices::Enumeration::DeviceInformation::FindAllAsync(selector) where selector is obtainable by Windows::Media::Devices::MediaDevice::GetAudioRenderSelector() or Windows::Media::Devices::MediaDevice::GetAudioCaptureSelector() API.
After the call completes, memory referenced by pointers can be freed, as implementation keeps its own copy.
You must call PaWasapi_UpdateDeviceList() to update the internal device list of the implementation after calling this function.
See an example in the IMPORTANT notes.
pId | Array of device Ids, pointer to the array of pointers of 16-bit Unicode string (WCHAR). If NULL and count is also 0 then device Ids will be reset to the default. Required. |
pName | Array of device Names, pointer to the array of pointers of 16-bit Unicode string (WCHAR). Optional. |
pRole | Array of device Roles, see PaWasapiDeviceRole and PaWasapi_GetDeviceRole() for more details. Optional. |
count | Number of devices, the number of array elements (pId, pName, pRole). Maximum count of devices is limited by PA_WASAPI_DEVICE_MAX_COUNT. |
bOutput | TRUE (1) for output (render), FALSE (0) for input (capture). |
References PA_WASAPI_DEVICE_ID_LEN, PA_WASAPI_DEVICE_NAME_LEN, paBufferTooBig, paIncompatibleStreamHostApi, paInsufficientMemory, paNoError, and STATIC_ARRAY_SIZE.
PaError PaWasapiWinrt_SetDefaultDeviceId | ( | const unsigned short * | pId, |
int | bOutput | ||
) |
Set default device Id.
By default implementation will use the DEVINTERFACE_AUDIO_RENDER and DEVINTERFACE_AUDIO_CAPTURE Ids if device Id is not provided explicitly. These default Ids will not allow to use Exclusive mode on UWP/WinRT platform and thus you must provide device Id explicitly via this API before calling the Pa_OpenStream().
Device Ids on UWP platform are obtainable via: Windows::Media::Devices::MediaDevice::GetDefaultAudioRenderId() or Windows::Media::Devices::MediaDevice::GetDefaultAudioCaptureId() API.
After the call completes, memory referenced by pointers can be freed, as implementation keeps its own copy.
Call this function before calling Pa_IsFormatSupported() when Exclusive mode is requested.
See an example in the IMPORTANT notes.
pId | Device Id, pointer to the 16-bit Unicode string (WCHAR). If NULL then device Id will be reset to the default, e.g. DEVINTERFACE_AUDIO_RENDER or DEVINTERFACE_AUDIO_CAPTURE. |
bOutput | TRUE (1) for output (render), FALSE (0) for input (capture). |
References PA_WASAPI_DEVICE_ID_LEN, paBufferTooBig, paIncompatibleStreamHostApi, paNoError, and STATIC_ARRAY_SIZE.