PortAudio
2.0
|
WASAPI implementation of support for a host API. More...
#include <windows.h>
#include <stddef.h>
#include <stdio.h>
#include <process.h>
#include <assert.h>
#include <mmreg.h>
#include <malloc.h>
#include <memory.h>
#include <mmsystem.h>
#include "pa_util.h"
#include "pa_allocation.h"
#include "pa_hostapi.h"
#include "pa_stream.h"
#include "pa_cpuload.h"
#include "pa_process.h"
#include "pa_debugprint.h"
#include "pa_ringbuffer.h"
#include "pa_win_version.h"
#include "pa_win_coinitialize.h"
#include "pa_win_wasapi.h"
#include <basetyps.h>
#include <rpcsal.h>
#include <sal.h>
#include <sdkddkver.h>
#include <propkeydef.h>
#include <audioclient.h>
#include <mmdeviceapi.h>
#include <endpointvolume.h>
#include <functiondiscoverykeys.h>
#include <devicetopology.h>
Data Structures | |
struct | _tagpropertykey |
struct | _BYTE_BLOB |
struct | WAVEFORMATEXTENSIBLE_IEC61937 |
union | _WAVEFORMATEXTENSIBLE_UNION |
struct | SystemTimer |
struct | PaWasapiDeviceInfo |
struct | PaWasapiHostApiRepresentation |
struct | PaWasapiAudioClientParams |
struct | PaWasapiSubStream |
struct | PaWasapiHostProcessor |
struct | PaWasapiStream |
struct | ThreadIdleScheduler |
Macros | |
#define | PA_WASAPI_MAX_CONST_DEVICE_COUNT 0 |
#define | WINVER 0x0600 |
Poll mode time slots logging. More... | |
#define | _WIN32_WINNT WINVER |
#define | WINAPI __stdcall |
#define | __unaligned |
#define | __C89_NAMELESS |
#define | __LPCGUID_DEFINED__ |
#define | PROPERTYKEY_DEFINED |
#define | __MIDL_CONST const |
#define | NONAMELESSUNION |
#define | WAVE_FORMAT_IEEE_FLOAT 0x0003 |
#define | __MINGW_EXTENSION |
#define | COBJMACROS |
#define | INITGUID |
#define | GUID_SECT |
#define | __DEFINE_GUID(n, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) static const GUID n GUID_SECT = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}} |
#define | __DEFINE_IID(n, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) static const IID n GUID_SECT = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}} |
#define | __DEFINE_CLSID(n, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) static const CLSID n GUID_SECT = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}} |
#define | PA_DEFINE_CLSID(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) __DEFINE_CLSID(pa_CLSID_##className, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8) |
#define | PA_DEFINE_IID(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) __DEFINE_IID(pa_IID_##interfaceName, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8) |
#define | _WAVEFORMATEXTENSIBLE_IEC61937_ |
#define | CREATE_THREAD(PROC) (HANDLE)_beginthreadex( NULL, 0, (PROC), stream, 0, &stream->dwThreadId ) |
#define | PA_THREAD_FUNC static unsigned WINAPI |
#define | PA_THREAD_ID unsigned |
#define | AUDCLNT_E_BUFFER_ERROR AUDCLNT_ERR(0x018) |
#define | AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED AUDCLNT_ERR(0x019) |
#define | AUDCLNT_E_INVALID_DEVICE_PERIOD AUDCLNT_ERR(0x020) |
#define | AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY 0x08000000 |
#define | AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM 0x80000000 |
#define | PA_WASAPI_DEVICE_ID_LEN 256 |
#define | PA_WASAPI_DEVICE_NAME_LEN 128 |
#define | STATIC_ARRAY_SIZE(array) (sizeof(array)/sizeof(array[0])) |
#define | PRINT(x) PA_DEBUG(x); |
#define | PA_SKELETON_SET_LAST_HOST_ERROR(errorCode, errorText) PaUtil_SetLastHostErrorInfo( paWASAPI, errorCode, errorText ) |
#define | PA_WASAPI__IS_FULLDUPLEX(STREAM) ((STREAM)->in.clientProc && (STREAM)->out.clientProc) |
#define | IF_FAILED_JUMP(hr, label) if(FAILED(hr)) goto label; |
#define | IF_FAILED_INTERNAL_ERROR_JUMP(hr, error, label) if(FAILED(hr)) { error = paInternalError; goto label; } |
#define | SAFE_CLOSE(h) if ((h) != NULL) { CloseHandle((h)); (h) = NULL; } |
#define | SAFE_RELEASE(punk) if ((punk) != NULL) { (punk)->lpVtbl->Release((punk)); (punk) = NULL; } |
#define | SAFE_ADDREF(punk) if ((punk) != NULL) { (punk)->lpVtbl->AddRef((punk)); } |
#define | _GetProc(fun, type, name) |
#define | LogHostError(HRES) __LogHostError(HRES, __FUNCTION__, __FILE__, __LINE__) |
#define | LogPaError(PAERR) __LogPaError(PAERR, __FUNCTION__, __FILE__, __LINE__) |
#define | HDA_PACKET_SIZE (128) |
#define | REFTIMES_PER_SEC 10000000LL |
#define | REFTIMES_PER_MILLISEC 10000LL |
#define | REFTIMES_PER_SEC 10000000LL |
#define | REFTIMES_PER_MILLISEC 10000LL |
#define | _WASAPI_MONO_TO_STEREO_MIXER_1_TO_2(TYPE) |
#define | _WASAPI_MONO_TO_STEREO_MIXER_2_TO_1_FLT32(TYPE) |
#define | _WASAPI_MONO_TO_STEREO_MIXER_2_TO_1_INT32(TYPE) |
#define | _WASAPI_MONO_TO_STEREO_MIXER_2_TO_1_INT64(TYPE) |
#define | _WASAPI_MONO_TO_STEREO_MIXER_2_TO_1_L(TYPE) |
#define | PA_WASAPI_LOOPBACK_NAME_IDENTIFICATOR "[Loopback]" |
Enumerations | |
enum | _AVRT_PRIORITY { AVRT_PRIORITY_LOW = -1, AVRT_PRIORITY_NORMAL, AVRT_PRIORITY_HIGH, AVRT_PRIORITY_CRITICAL } |
enum | { S_INPUT = 0, S_OUTPUT = 1, S_COUNT = 2, S_FULLDUPLEX = 0 } |
enum | { WASAPI_PACKETS_PER_INPUT_BUFFER = 6 } |
enum | EMixDirection { MIX_DIR__1TO2, MIX_DIR__2TO1, MIX_DIR__2TO1_L } |
Functions | |
PA_DEFINE_IID (IAudioClient, 1cb9ad4c, dbfa, 4c32, b1, 78, c2, f5, 68, a7, 03, b2) | |
PA_DEFINE_IID (IAudioClient2, 726778cd, f60a, 4eda, 82, de, e4, 76, 10, cd, 78, aa) | |
PA_DEFINE_IID (IAudioClient3, 7ed4ee07, 8e67, 4cd4, 8c, 1a, 2b, 7a, 59, 87, ad, 42) | |
PA_DEFINE_IID (IMMEndpoint, 1be09788, 6894, 4089, 85, 86, 9a, 2a, 6c, 26, 5a, c5) | |
PA_DEFINE_IID (IMMDeviceEnumerator, a95664d2, 9614, 4f35, a7, 46, de, 8d, b6, 36, 17, e6) | |
PA_DEFINE_CLSID (IMMDeviceEnumerator, bcde0395, e52f, 467c, 8e, 3d, c4, 57, 92, 91, 69, 2e) | |
PA_DEFINE_IID (IAudioRenderClient, f294acfc, 3146, 4483, a7, bf, ad, dc, a7, c2, 60, e2) | |
PA_DEFINE_IID (IAudioCaptureClient, c8adbd64, e71e, 48a0, a4, de, 18, 5c, 39, 5c, d3, 17) | |
PA_DEFINE_IID (IDeviceTopology, 2A07407E, 6497, 4A18, 97, 87, 32, f7, 9b, d0, d9, 8f) | |
PA_DEFINE_IID (IPart, AE2DE0E4, 5BCA, 4F2D, aa, 46, 5d, 13, f8, fd, b3, a9) | |
PA_DEFINE_IID (IKsJackDescription, 4509F757, 2D46, 4637, 8e, 62, ce, 7d, b9, 44, f5, 7b) | |
__DEFINE_GUID (pa_KSDATAFORMAT_SUBTYPE_PCM, 0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71) | |
__DEFINE_GUID (pa_KSDATAFORMAT_SUBTYPE_ADPCM, 0x00000002, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71) | |
__DEFINE_GUID (pa_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71) | |
__DEFINE_GUID (pa_KSDATAFORMAT_SUBTYPE_IEC61937_PCM, 0x00000000, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71) | |
PA_THREAD_FUNC | ProcThreadEvent (void *param) |
PA_THREAD_FUNC | ProcThreadPoll (void *param) |
typedef | BOOL (WINAPI *FAvRtCreateThreadOrderingGroup)(PHANDLE |
typedef | HANDLE (WINAPI *FAvSetMmThreadCharacteristics)(LPCSTR |
PaError | PaWasapi_Initialize (PaUtilHostApiRepresentation **hostApi, PaHostApiIndex index) |
PaError | PaWasapi_UpdateDeviceList () |
int | PaWasapi_GetDeviceCurrentFormat (PaStream *pStream, void *pFormat, unsigned int formatSize, int bOutput) |
int | PaWasapi_GetDeviceDefaultFormat (void *pFormat, unsigned int formatSize, PaDeviceIndex device) |
int | PaWasapi_GetDeviceMixFormat (void *pFormat, unsigned int formatSize, PaDeviceIndex device) |
int | PaWasapi_GetDeviceRole (PaDeviceIndex device) |
PaError | PaWasapi_GetIMMDevice (PaDeviceIndex device, void **pIMMDevice) |
int | PaWasapi_IsLoopback (PaDeviceIndex device) |
PaError | PaWasapi_GetFramesPerHostBuffer (PaStream *pStream, unsigned int *pInput, unsigned int *pOutput) |
unsigned long | PaUtil_GetOutputFrameCount (PaUtilBufferProcessor *bp) |
PaError | PaWasapi_ThreadPriorityBoost (void **pTask, PaWasapiThreadPriority priorityClass) |
PaError | PaWasapi_ThreadPriorityRevert (void *pTask) |
PaError | PaWasapi_GetJackCount (PaDeviceIndex device, int *pJackCount) |
PaError | PaWasapi_GetJackDescription (PaDeviceIndex device, int jackIndex, PaWasapiJackDescription *pJackDescription) |
PaError | PaWasapi_GetAudioClient (PaStream *pStream, void **pAudioClient, int bOutput) |
PaError | PaWasapiWinrt_SetDefaultDeviceId (const unsigned short *pId, int bOutput) |
PaError | PaWasapiWinrt_PopulateDeviceList (const unsigned short **pId, const unsigned short **pName, const PaWasapiDeviceRole *pRole, unsigned int count, int bOutput) |
PaError | PaWasapi_SetStreamStateHandler (PaStream *pStream, PaWasapiStreamStateCallback fnStateHandler, void *pUserData) |
Variables | |
typedef | LPDWORD |
FAvRtCreateThreadOrderingGroup | pAvRtCreateThreadOrderingGroup = NULL |
FAvRtDeleteThreadOrderingGroup | pAvRtDeleteThreadOrderingGroup = NULL |
FAvRtWaitOnThreadOrderingGroup | pAvRtWaitOnThreadOrderingGroup = NULL |
FAvSetMmThreadCharacteristics | pAvSetMmThreadCharacteristics = NULL |
FAvRevertMmThreadCharacteristics | pAvRevertMmThreadCharacteristics = NULL |
FAvSetMmThreadPriority | pAvSetMmThreadPriority = NULL |
WASAPI implementation of support for a host API.
#define __C89_NAMELESS |
#define __DEFINE_CLSID | ( | n, | |
l, | |||
w1, | |||
w2, | |||
b1, | |||
b2, | |||
b3, | |||
b4, | |||
b5, | |||
b6, | |||
b7, | |||
b8 | |||
) | static const CLSID n GUID_SECT = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}} |
#define __DEFINE_GUID | ( | n, | |
l, | |||
w1, | |||
w2, | |||
b1, | |||
b2, | |||
b3, | |||
b4, | |||
b5, | |||
b6, | |||
b7, | |||
b8 | |||
) | static const GUID n GUID_SECT = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}} |
#define __DEFINE_IID | ( | n, | |
l, | |||
w1, | |||
w2, | |||
b1, | |||
b2, | |||
b3, | |||
b4, | |||
b5, | |||
b6, | |||
b7, | |||
b8 | |||
) | static const IID n GUID_SECT = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}} |
#define __LPCGUID_DEFINED__ |
#define __MIDL_CONST const |
#define __MINGW_EXTENSION |
#define __unaligned |
#define _GetProc | ( | fun, | |
type, | |||
name | |||
) |
#define _WASAPI_MONO_TO_STEREO_MIXER_1_TO_2 | ( | TYPE | ) |
#define _WASAPI_MONO_TO_STEREO_MIXER_2_TO_1_FLT32 | ( | TYPE | ) |
#define _WASAPI_MONO_TO_STEREO_MIXER_2_TO_1_INT32 | ( | TYPE | ) |
#define _WASAPI_MONO_TO_STEREO_MIXER_2_TO_1_INT64 | ( | TYPE | ) |
#define _WASAPI_MONO_TO_STEREO_MIXER_2_TO_1_L | ( | TYPE | ) |
#define _WAVEFORMATEXTENSIBLE_IEC61937_ |
#define _WIN32_WINNT WINVER |
#define AUDCLNT_E_BUFFER_ERROR AUDCLNT_ERR(0x018) |
#define AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED AUDCLNT_ERR(0x019) |
#define AUDCLNT_E_INVALID_DEVICE_PERIOD AUDCLNT_ERR(0x020) |
#define AUDCLNT_STREAMFLAGS_AUTOCONVERTPCM 0x80000000 |
#define AUDCLNT_STREAMFLAGS_SRC_DEFAULT_QUALITY 0x08000000 |
#define COBJMACROS |
#define CREATE_THREAD | ( | PROC | ) | (HANDLE)_beginthreadex( NULL, 0, (PROC), stream, 0, &stream->dwThreadId ) |
#define GUID_SECT |
#define HDA_PACKET_SIZE (128) |
#define IF_FAILED_INTERNAL_ERROR_JUMP | ( | hr, | |
error, | |||
label | |||
) | if(FAILED(hr)) { error = paInternalError; goto label; } |
#define IF_FAILED_JUMP | ( | hr, | |
label | |||
) | if(FAILED(hr)) goto label; |
Referenced by PaWasapi_GetJackCount(), and PaWasapi_GetJackDescription().
#define INITGUID |
#define LogHostError | ( | HRES | ) | __LogHostError(HRES, __FUNCTION__, __FILE__, __LINE__) |
Referenced by PaWasapi_GetJackCount(), PaWasapi_GetJackDescription(), ProcThreadEvent(), and ProcThreadPoll().
#define LogPaError | ( | PAERR | ) | __LogPaError(PAERR, __FUNCTION__, __FILE__, __LINE__) |
#define NONAMELESSUNION |
#define PA_DEFINE_CLSID | ( | className, | |
l, | |||
w1, | |||
w2, | |||
b1, | |||
b2, | |||
b3, | |||
b4, | |||
b5, | |||
b6, | |||
b7, | |||
b8 | |||
) | __DEFINE_CLSID(pa_CLSID_##className, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8) |
#define PA_DEFINE_IID | ( | interfaceName, | |
l, | |||
w1, | |||
w2, | |||
b1, | |||
b2, | |||
b3, | |||
b4, | |||
b5, | |||
b6, | |||
b7, | |||
b8 | |||
) | __DEFINE_IID(pa_IID_##interfaceName, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8) |
#define PA_SKELETON_SET_LAST_HOST_ERROR | ( | errorCode, | |
errorText | |||
) | PaUtil_SetLastHostErrorInfo( paWASAPI, errorCode, errorText ) |
#define PA_THREAD_FUNC static unsigned WINAPI |
#define PA_THREAD_ID unsigned |
#define PA_WASAPI__IS_FULLDUPLEX | ( | STREAM | ) | ((STREAM)->in.clientProc && (STREAM)->out.clientProc) |
Referenced by ProcThreadPoll().
#define PA_WASAPI_DEVICE_ID_LEN 256 |
Referenced by PaWasapiWinrt_PopulateDeviceList(), and PaWasapiWinrt_SetDefaultDeviceId().
#define PA_WASAPI_DEVICE_NAME_LEN 128 |
Referenced by PaWasapiWinrt_PopulateDeviceList().
#define PA_WASAPI_LOOPBACK_NAME_IDENTIFICATOR "[Loopback]" |
#define PA_WASAPI_MAX_CONST_DEVICE_COUNT 0 |
#define PRINT | ( | x | ) | PA_DEBUG(x); |
Referenced by PaWasapi_Initialize(), and ProcThreadEvent().
#define PROPERTYKEY_DEFINED |
#define REFTIMES_PER_MILLISEC 10000LL |
#define REFTIMES_PER_MILLISEC 10000LL |
#define REFTIMES_PER_SEC 10000000LL |
#define REFTIMES_PER_SEC 10000000LL |
#define SAFE_ADDREF | ( | punk | ) | if ((punk) != NULL) { (punk)->lpVtbl->AddRef((punk)); } |
#define SAFE_CLOSE | ( | h | ) | if ((h) != NULL) { CloseHandle((h)); (h) = NULL; } |
#define SAFE_RELEASE | ( | punk | ) | if ((punk) != NULL) { (punk)->lpVtbl->Release((punk)); (punk) = NULL; } |
Referenced by PaWasapi_GetJackCount(), and PaWasapi_GetJackDescription().
#define STATIC_ARRAY_SIZE | ( | array | ) | (sizeof(array)/sizeof(array[0])) |
Referenced by PaWasapiWinrt_PopulateDeviceList(), and PaWasapiWinrt_SetDefaultDeviceId().
#define WAVE_FORMAT_IEEE_FLOAT 0x0003 |
#define WINAPI __stdcall |
Referenced by PaWinDs_InitializeDSoundEntryPoints(), and PaWinWdm_Initialize().
#define WINVER 0x0600 |
Poll mode time slots logging.
typedef UINT32(* ALIGN_FUNC)(UINT32 v, UINT32 align) |
typedef AVRT_PRIORITY |
typedef struct _BYTE_BLOB BYTE_BLOB |
typedef GUID CLSID |
typedef enum EMixDirection EMixDirection |
typedef GUID IID |
typedef const GUID* LPCGUID |
typedef void(* MixMonoToStereoF)(void *__to, const void *__from, UINT32 count) |
typedef LONG NTSTATUS |
typedef enum _AVRT_PRIORITY * PAVRT_PRIORITY |
typedef struct PaWasapiAudioClientParams PaWasapiAudioClientParams |
typedef struct PaWasapiDeviceInfo PaWasapiDeviceInfo |
typedef struct PaWasapiHostApiRepresentation PaWasapiHostApiRepresentation |
typedef struct PaWasapiHostProcessor PaWasapiHostProcessor |
typedef struct PaWasapiStream PaWasapiStream |
typedef struct PaWasapiSubStream PaWasapiSubStream |
typedef PLARGE_INTEGER |
typedef struct _tagpropertykey PROPERTYKEY |
typedef struct WAVEFORMATEXTENSIBLE_IEC61937 * PWAVEFORMATEXTENSIBLE_IEC61937 |
typedef LONGLONG REFERENCE_TIME |
typedef struct SystemTimer SystemTimer |
typedef struct ThreadIdleScheduler ThreadIdleScheduler |
typedef __RPC_unique_pointer BYTE_BLOB* UP_BYTE_BLOB |
typedef union _WAVEFORMATEXTENSIBLE_UNION WAVEFORMATEXTENSIBLE_UNION |
enum _AVRT_PRIORITY |
enum EMixDirection |
__DEFINE_GUID | ( | pa_KSDATAFORMAT_SUBTYPE_PCM | , |
0x00000001 | , | ||
0x0000 | , | ||
0x0010 | , | ||
0x80 | , | ||
0x00 | , | ||
0x00 | , | ||
0xaa | , | ||
0x00 | , | ||
0x38 | , | ||
0x9b | , | ||
0x71 | |||
) |
__DEFINE_GUID | ( | pa_KSDATAFORMAT_SUBTYPE_ADPCM | , |
0x00000002 | , | ||
0x0000 | , | ||
0x0010 | , | ||
0x80 | , | ||
0x00 | , | ||
0x00 | , | ||
0xaa | , | ||
0x00 | , | ||
0x38 | , | ||
0x9b | , | ||
0x71 | |||
) |
__DEFINE_GUID | ( | pa_KSDATAFORMAT_SUBTYPE_IEEE_FLOAT | , |
0x00000003 | , | ||
0x0000 | , | ||
0x0010 | , | ||
0x80 | , | ||
0x00 | , | ||
0x00 | , | ||
0xaa | , | ||
0x00 | , | ||
0x38 | , | ||
0x9b | , | ||
0x71 | |||
) |
__DEFINE_GUID | ( | pa_KSDATAFORMAT_SUBTYPE_IEC61937_PCM | , |
0x00000000 | , | ||
0x0000 | , | ||
0x0010 | , | ||
0x80 | , | ||
0x00 | , | ||
0x00 | , | ||
0xaa | , | ||
0x00 | , | ||
0x38 | , | ||
0x9b | , | ||
0x71 | |||
) |
typedef BOOL | ( | WINAPI * | FAvRtCreateThreadOrderingGroup | ) |
Referenced by PaWinWdm_Initialize(), ProcThreadEvent(), and ProcThreadPoll().
typedef HANDLE | ( | WINAPI * | FAvSetMmThreadCharacteristics | ) |
PA_DEFINE_CLSID | ( | IMMDeviceEnumerator | , |
bcde0395 | , | ||
e52f | , | ||
467c | , | ||
8e | , | ||
3d | , | ||
c4 | , | ||
57 | , | ||
92 | , | ||
91 | , | ||
69 | , | ||
2e | |||
) |
PA_DEFINE_IID | ( | IAudioClient | , |
1cb9ad4c | , | ||
dbfa | , | ||
4c32 | , | ||
b1 | , | ||
78 | , | ||
c2 | , | ||
f5 | , | ||
68 | , | ||
a7 | , | ||
03 | , | ||
b2 | |||
) |
PA_DEFINE_IID | ( | IAudioClient2 | , |
726778cd | , | ||
f60a | , | ||
4eda | , | ||
82 | , | ||
de | , | ||
e4 | , | ||
76 | , | ||
10 | , | ||
cd | , | ||
78 | , | ||
aa | |||
) |
PA_DEFINE_IID | ( | IAudioClient3 | , |
7ed4ee07 | , | ||
8e67 | , | ||
4cd4 | , | ||
8c | , | ||
1a | , | ||
2b | , | ||
7a | , | ||
59 | , | ||
87 | , | ||
ad | , | ||
42 | |||
) |
PA_DEFINE_IID | ( | IMMEndpoint | , |
1be09788 | , | ||
6894 | , | ||
4089 | , | ||
85 | , | ||
86 | , | ||
9a | , | ||
2a | , | ||
6c | , | ||
26 | , | ||
5a | , | ||
c5 | |||
) |
PA_DEFINE_IID | ( | IMMDeviceEnumerator | , |
a95664d2 | , | ||
9614 | , | ||
4f35 | , | ||
a7 | , | ||
46 | , | ||
de | , | ||
8d | , | ||
b6 | , | ||
36 | , | ||
17 | , | ||
e6 | |||
) |
PA_DEFINE_IID | ( | IAudioRenderClient | , |
f294acfc | , | ||
3146 | , | ||
4483 | , | ||
a7 | , | ||
bf | , | ||
ad | , | ||
dc | , | ||
a7 | , | ||
c2 | , | ||
60 | , | ||
e2 | |||
) |
PA_DEFINE_IID | ( | IAudioCaptureClient | , |
c8adbd64 | , | ||
e71e | , | ||
48a0 | , | ||
a4 | , | ||
de | , | ||
18 | , | ||
5c | , | ||
39 | , | ||
5c | , | ||
d3 | , | ||
17 | |||
) |
PA_DEFINE_IID | ( | IDeviceTopology | , |
2A07407E | , | ||
6497 | , | ||
4A18 | , | ||
97 | , | ||
87 | , | ||
32 | , | ||
f7 | , | ||
9b | , | ||
d0 | , | ||
d9 | , | ||
8f | |||
) |
PA_DEFINE_IID | ( | IPart | , |
AE2DE0E4 | , | ||
5BCA | , | ||
4F2D | , | ||
aa | , | ||
46 | , | ||
5d | , | ||
13 | , | ||
f8 | , | ||
fd | , | ||
b3 | , | ||
a9 | |||
) |
PA_DEFINE_IID | ( | IKsJackDescription | , |
4509F757 | , | ||
2D46 | , | ||
4637 | , | ||
8e | , | ||
62 | , | ||
ce | , | ||
7d | , | ||
b9 | , | ||
44 | , | ||
f5 | , | ||
7b | |||
) |
unsigned long PaUtil_GetOutputFrameCount | ( | PaUtilBufferProcessor * | bp | ) |
References PaUtilBufferProcessor::hostOutputFrameCount.
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 overridden 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 _WAVEFORMATEXTENSIBLE_UNION::ext, PaWasapiStream::in, PaWasapiStream::out, paBadStreamPtr, TRUE, and PaWasapiSubStream::wavexu.
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, paBadBufferPtr, paBufferTooSmall, and paNoError.
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 PaWasapiDeviceInfo::MixFormat, paBadBufferPtr, paBufferTooSmall, and paNoError.
int PaWasapi_GetDeviceRole | ( | PaDeviceIndex | device | ) |
Get device role (PaWasapiDeviceRole enum).
device | Device index. |
References PaWasapiDeviceInfo::formFactor, and paNoError.
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 find out 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_GetIMMDevice | ( | PaDeviceIndex | device, |
void ** | pIMMDevice | ||
) |
Get device IMMDevice pointer.
device | Device index. |
pAudioClient | Pointer to pointer of IMMDevice. |
References PaWasapiDeviceInfo::device, paBadBufferPtr, paIncompatibleStreamHostApi, 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, IF_FAILED_JUMP, LogHostError, paNoError, paUnanticipatedHostError, 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, PaWasapiJackDescription::genLocation, PaWasapiJackDescription::geoLocation, IF_FAILED_JUMP, PaWasapiJackDescription::isConnected, LogHostError, paNoError, paUnanticipatedHostError, PaWasapiJackDescription::portConnection, and SAFE_RELEASE.
PaError PaWasapi_Initialize | ( | PaUtilHostApiRepresentation ** | hostApi, |
PaHostApiIndex | index | ||
) |
References PaWasapiHostApiRepresentation::allocations, PaWasapiHostApiRepresentation::blockingStreamInterface, PaWasapiHostApiRepresentation::callbackStreamInterface, PaWasapiHostApiRepresentation::comInitializationResult, GetStreamCpuLoad(), GetStreamReadAvailable(), GetStreamTime(), GetStreamWriteAvailable(), PaUtilHostApiRepresentation::info, PaWasapiHostApiRepresentation::inheritedHostApiRep, IsFormatSupported(), IsStreamActive(), IsStreamStopped(), OpenStream(), Pa_GetErrorText(), paInsufficientMemory, paNoDevice, paNoError, paOsVersionWindowsVistaServer2008, PaUtil_AllocateZeroInitializedMemory(), PaUtil_CreateAllocationGroup(), PaUtil_DummyGetCpuLoad(), PaUtil_DummyGetReadAvailable(), PaUtil_DummyGetWriteAvailable(), PaUtil_DummyRead(), PaUtil_DummyWrite(), PaUtil_InitializeStreamInterface(), paWASAPI, PaWinUtil_CoInitialize(), PaWinUtil_GetOsVersion(), PRINT, ReadStream(), PaHostApiInfo::structVersion, Terminate(), PaWasapiHostApiRepresentation::useWOW64Workaround, and WriteStream().
int PaWasapi_IsLoopback | ( | PaDeviceIndex | device | ) |
Get device loopback state:
0 - Not loopback, 1 - Loopback, negative - PaErrorCode.
device | Device index. |
References PaWasapiHostApiRepresentation::deviceCount, PaWasapiHostApiRepresentation::devInfo, PaWasapiHostApiRepresentation::inheritedHostApiRep, PaWasapiDeviceInfo::loopBack, paInvalidDevice, paNoError, paNotInitialized, and PaUtil_DeviceIndexToHostApiDeviceIndex().
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().
References paInternalError.
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.
PA_THREAD_FUNC ProcThreadEvent | ( | void * | param | ) |
References BOOL(), PaWasapiStream::captureClient, PaWasapiSubStream::clientProc, PaWasapiStream::event, FALSE, PaWasapiSubStream::framesPerBuffer, PaWasapiStream::hAvTask, PaWasapiStream::hostProcessOverrideInput, PaWasapiStream::hostProcessOverrideOutput, PaWasapiStream::hThreadExit, PaWasapiStream::hThreadStart, PaWasapiStream::in, PaWasapiStream::isActive, LogHostError, PaWasapiStream::nThreadPriority, PaWasapiStream::out, paUnanticipatedHostError, PaWasapi_ThreadPriorityBoost(), paWasapiStreamStateThreadPrepare, paWasapiStreamStateThreadStart, paWasapiStreamStateThreadStop, PRINT, PaWasapiHostProcessor::processor, PaWasapiStream::renderClient, S_COUNT, S_INPUT, S_OUTPUT, PaWasapiSubStream::shareMode, TRUE, and PaWasapiHostProcessor::userData.
PA_THREAD_FUNC ProcThreadPoll | ( | void * | param | ) |
Do first loop without waiting as time could be spent when calling other APIs before ProcessXXXBuffer.
References BOOL(), PaWasapiStream::bufferMode, PaWasapiStream::captureClient, PaWasapiSubStream::clientProc, FALSE, PaWasapiSubStream::framesPerBuffer, PaWasapiStream::hAvTask, PaWasapiStream::hostProcessOverrideInput, PaWasapiStream::hostProcessOverrideOutput, PaWasapiStream::hThreadExit, PaWasapiStream::hThreadStart, PaWasapiStream::in, PaWasapiStream::isActive, LogHostError, PaWasapiSubStream::monoBuffer, PaWasapiSubStream::monoMixer, PaWasapiStream::nThreadPriority, PaWasapiStream::out, PA_WASAPI__IS_FULLDUPLEX, paUnanticipatedHostError, paUtilFixedHostBufferSize, PaWasapi_ThreadPriorityBoost(), paWasapiStreamStateThreadPrepare, paWasapiStreamStateThreadStart, paWasapiStreamStateThreadStop, PaWasapiHostProcessor::processor, PaWasapiStream::renderClient, S_COUNT, S_FULLDUPLEX, S_INPUT, S_OUTPUT, PaWasapiSubStream::shareMode, PaWasapiStream::timer, TRUE, and PaWasapiHostProcessor::userData.
typedef LPDWORD |
Referenced by PaWinWdm_Initialize().
FAvRevertMmThreadCharacteristics pAvRevertMmThreadCharacteristics = NULL |
FAvRtCreateThreadOrderingGroup pAvRtCreateThreadOrderingGroup = NULL |
FAvRtDeleteThreadOrderingGroup pAvRtDeleteThreadOrderingGroup = NULL |
FAvRtWaitOnThreadOrderingGroup pAvRtWaitOnThreadOrderingGroup = NULL |
FAvSetMmThreadCharacteristics pAvSetMmThreadCharacteristics = NULL |
FAvSetMmThreadPriority pAvSetMmThreadPriority = NULL |