PortAudio  2.0
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
pa_win_wasapi.c File Reference

WASAPI implementation of support for a host API. More...

#include <windows.h>
#include <stdio.h>
#include <process.h>
#include <assert.h>
#include <mmsystem.h>
#include <mmreg.h>
#include <malloc.h>
#include <memory.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_win_wasapi.h"
#include "pa_debugprint.h"
#include "pa_ringbuffer.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  PaWasapiDeviceInfo
 
struct  PaWasapiHostApiRepresentation
 
struct  PaWasapiAudioClientParams
 
struct  PaWasapiSubStream
 
struct  PaWasapiHostProcessor
 
struct  PaWasapiStream
 
struct  ThreadIdleScheduler
 

Macros

#define WIN32_LEAN_AND_MEAN
 
#define WINVER   0x0600
 
#define _WIN32_WINNT   WINVER
 
#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 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 MAX_STR_LEN   512
 
#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 _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   10000000
 
#define REFTIMES_PER_MILLISEC   10000
 
#define REFTIMES_PER_SEC   10000000
 
#define REFTIMES_PER_MILLISEC   10000
 
#define WINDOWS_7_SERVER2008R2_AND_UP   (WINDOWS_7_SERVER2008R2|WINDOWS_FUTURE)
 
#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)
 

Typedefs

typedef enum _AVRT_PRIORITY AVRT_PRIORITY
 
typedef enum _AVRT_PRIORITYPAVRT_PRIORITY
 
typedef const GUID * LPCGUID
 
typedef struct _tagpropertykey PROPERTYKEY
 
typedef struct _BYTE_BLOB BYTE_BLOB
 
typedef __RPC_unique_pointer
BYTE_BLOB
UP_BYTE_BLOB
 
typedef LONGLONG REFERENCE_TIME
 
typedef void(* MixMonoToStereoF )(void *__to, void *__from, UINT32 count)
 
typedef GUID PLARGE_INTEGER
 
typedef BOOL(WINAPI * FAvRevertMmThreadCharacteristics )(HANDLE)
 
typedef struct PaWasapiDeviceInfo PaWasapiDeviceInfo
 
typedef struct
PaWasapiAudioClientParams 
PaWasapiAudioClientParams
 
typedef struct PaWasapiSubStream PaWasapiSubStream
 
typedef struct
PaWasapiHostProcessor 
PaWasapiHostProcessor
 
typedef struct PaWasapiStream PaWasapiStream
 
typedef struct ThreadIdleScheduler ThreadIdleScheduler
 
typedef UINT32(* ALIGN_FUNC )(UINT32 v, UINT32 align)
 
typedef enum EWindowsVersion EWindowsVersion
 
typedef enum EMixerDir EMixerDir
 

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  EWindowsVersion { WINDOWS_UNKNOWN = 0, WINDOWS_VISTA_SERVER2008 = (1 << 0), WINDOWS_7_SERVER2008R2 = (1 << 1), WINDOWS_FUTURE = (1 << 2) }
 
enum  EMixerDir { 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 (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)
 
PA_THREAD_FUNC ProcThreadEvent (void *param)
 
PA_THREAD_FUNC ProcThreadPoll (void *param)
 
typedef BOOL (WINAPI *FAvRtCreateThreadOrderingGroup)(PHANDLE
 
typedef HANDLE (WINAPI *FAvSetMmThreadCharacteristics)(LPCTSTR
 
PaError PaWasapi_Initialize (PaUtilHostApiRepresentation **hostApi, PaHostApiIndex index)
 
void _StreamOnStop (PaWasapiStream *stream)
 
void _StreamFinish (PaWasapiStream *stream)
 
void _StreamCleanup (PaWasapiStream *stream)
 
HRESULT _PollGetOutputFramesAvailable (PaWasapiStream *stream, UINT32 *available)
 
HRESULT _PollGetInputFramesAvailable (PaWasapiStream *stream, UINT32 *available)
 
void * PaWasapi_ReallocateMemory (void *ptr, size_t size)
 
void PaWasapi_FreeMemory (void *ptr)
 
UINT32 ALIGN_NEXT_POW2 (UINT32 v)
 
int PaWasapi_GetDeviceDefaultFormat (void *pFormat, unsigned int nFormatSize, PaDeviceIndex nDevice)
 
int PaWasapi_GetDeviceRole (PaDeviceIndex nDevice)
 
PaError PaWasapi_GetFramesPerHostBuffer (PaStream *pStream, unsigned int *nInput, unsigned int *nOutput)
 
HRESULT UnmarshalSubStreamComPointers (PaWasapiSubStream *substream)
 
HRESULT UnmarshalStreamComPointers (PaWasapiStream *stream)
 
void ReleaseUnmarshaledSubComPointers (PaWasapiSubStream *substream)
 
void ReleaseUnmarshaledComPointers (PaWasapiStream *stream)
 
HRESULT MarshalSubStreamComPointers (PaWasapiSubStream *substream)
 
HRESULT MarshalStreamComPointers (PaWasapiStream *stream)
 
unsigned long PaUtil_GetOutputFrameCount (PaUtilBufferProcessor *bp)
 
HANDLE MMCSS_activate (const char *name)
 
void MMCSS_deactivate (HANDLE hTask)
 
PaError PaWasapi_ThreadPriorityBoost (void **hTask, PaWasapiThreadPriority nPriorityClass)
 
PaError PaWasapi_ThreadPriorityRevert (void *hTask)
 
PaError PaWasapi_GetJackCount (PaDeviceIndex nDevice, int *jcount)
 
PaError PaWasapi_GetJackDescription (PaDeviceIndex nDevice, int jindex, PaWasapiJackDescription *pJackDescription)
 
HRESULT ProcessOutputBuffer (PaWasapiStream *stream, PaWasapiHostProcessor *processor, UINT32 frames)
 
HRESULT ProcessInputBuffer (PaWasapiStream *stream, PaWasapiHostProcessor *processor)
 

Variables

typedef LPDWORD
 
FAvRtCreateThreadOrderingGroup pAvRtCreateThreadOrderingGroup = NULL
 
FAvRtDeleteThreadOrderingGroup pAvRtDeleteThreadOrderingGroup = NULL
 
FAvRtWaitOnThreadOrderingGroup pAvRtWaitOnThreadOrderingGroup = NULL
 
FAvSetMmThreadCharacteristics pAvSetMmThreadCharacteristics = NULL
 
FAvRevertMmThreadCharacteristics pAvRevertMmThreadCharacteristics = NULL
 
FAvSetMmThreadPriority pAvSetMmThreadPriority = NULL
 

Detailed Description

WASAPI implementation of support for a host API.

Note
pa_wasapi currently requires minimum VC 2005, and the latest Vista SDK

Macro Definition Documentation

#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 _GetProc (   fun,
  type,
  name 
)
Value:
{ \
fun = (type) GetProcAddress(hDInputDLL,name); \
if (fun == NULL) { \
PRINT(("GetProcAddr failed for %s" ,name)); \
return FALSE; \
} \
} \
#define _WASAPI_MONO_TO_STEREO_MIXER_1_TO_2 (   TYPE)
Value:
TYPE * __restrict to = __to;\
TYPE * __restrict from = __from;\
TYPE * __restrict end = from + count;\
while (from != end)\
{\
*to ++ = *from;\
*to ++ = *from;\
++ from;\
}
#define _WASAPI_MONO_TO_STEREO_MIXER_2_TO_1_FLT32 (   TYPE)
Value:
TYPE * __restrict to = (TYPE *)__to;\
TYPE * __restrict from = (TYPE *)__from;\
TYPE * __restrict end = to + count;\
while (to != end)\
{\
*to ++ = (TYPE)((float)(from[0] + from[1]) * 0.5f);\
from += 2;\
}
#define _WASAPI_MONO_TO_STEREO_MIXER_2_TO_1_INT32 (   TYPE)
Value:
TYPE * __restrict to = (TYPE *)__to;\
TYPE * __restrict from = (TYPE *)__from;\
TYPE * __restrict end = to + count;\
while (to != end)\
{\
*to ++ = (TYPE)(((INT32)from[0] + (INT32)from[1]) >> 1);\
from += 2;\
}
#define _WASAPI_MONO_TO_STEREO_MIXER_2_TO_1_INT64 (   TYPE)
Value:
TYPE * __restrict to = (TYPE *)__to;\
TYPE * __restrict from = (TYPE *)__from;\
TYPE * __restrict end = to + count;\
while (to != end)\
{\
*to ++ = (TYPE)(((INT64)from[0] + (INT64)from[1]) >> 1);\
from += 2;\
}
#define _WASAPI_MONO_TO_STEREO_MIXER_2_TO_1_L (   TYPE)
Value:
TYPE * __restrict to = (TYPE *)__to;\
TYPE * __restrict from = (TYPE *)__from;\
TYPE * __restrict end = to + count;\
while (to != end)\
{\
*to ++ = from[0];\
from += 2;\
}
#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 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; }

Referenced by PaWasapi_Initialize().

#define IF_FAILED_JUMP (   hr,
  label 
)    if(FAILED(hr)) goto label;
#define INITGUID
#define LogHostError (   HRES)    __LogHostError(HRES, __FUNCTION__, __FILE__, __LINE__)
#define LogPaError (   PAERR)    __LogPaError(PAERR, __FUNCTION__, __FILE__, __LINE__)

Referenced by ProcThreadPoll().

#define MAX_STR_LEN   512

Referenced by PaWasapi_Initialize().

#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 PRINT (   x)    PA_DEBUG(x);
#define PROPERTYKEY_DEFINED
#define REFTIMES_PER_MILLISEC   10000
#define REFTIMES_PER_MILLISEC   10000
#define REFTIMES_PER_SEC   10000000
#define REFTIMES_PER_SEC   10000000
#define SAFE_CLOSE (   h)    if ((h) != NULL) { CloseHandle((h)); (h) = NULL; }

Referenced by _StreamCleanup().

#define SAFE_RELEASE (   punk)    if ((punk) != NULL) { (punk)->lpVtbl->Release((punk)); (punk) = NULL; }
#define STATIC_ARRAY_SIZE (   array)    (sizeof(array)/sizeof(array[0]))
#define WAVE_FORMAT_IEEE_FLOAT   0x0003
#define WIN32_LEAN_AND_MEAN
#define WINDOWS_7_SERVER2008R2_AND_UP   (WINDOWS_7_SERVER2008R2|WINDOWS_FUTURE)
#define WINVER   0x0600

Typedef Documentation

typedef UINT32(* ALIGN_FUNC)(UINT32 v, UINT32 align)
typedef AVRT_PRIORITY
typedef struct _BYTE_BLOB BYTE_BLOB
typedef enum EMixerDir EMixerDir
typedef BOOL(WINAPI * FAvRevertMmThreadCharacteristics)(HANDLE)
typedef const GUID* LPCGUID
typedef void(* MixMonoToStereoF)(void *__to, void *__from, UINT32 count)
typedef PLARGE_INTEGER
typedef struct _tagpropertykey PROPERTYKEY
typedef LONGLONG REFERENCE_TIME

Enumeration Type Documentation

anonymous enum
Enumerator
S_INPUT 
S_OUTPUT 
S_COUNT 
S_FULLDUPLEX 
anonymous enum
Enumerator
WASAPI_PACKETS_PER_INPUT_BUFFER 
Enumerator
AVRT_PRIORITY_LOW 
AVRT_PRIORITY_NORMAL 
AVRT_PRIORITY_HIGH 
AVRT_PRIORITY_CRITICAL 
enum EMixerDir
Enumerator
MIX_DIR__1TO2 
MIX_DIR__2TO1 
MIX_DIR__2TO1_L 
Enumerator
WINDOWS_UNKNOWN 
WINDOWS_VISTA_SERVER2008 
WINDOWS_7_SERVER2008R2 
WINDOWS_FUTURE 

Function Documentation

__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   
)
HRESULT _PollGetInputFramesAvailable ( PaWasapiStream stream,
UINT32 *  available 
)
HRESULT _PollGetOutputFramesAvailable ( PaWasapiStream stream,
UINT32 *  available 
)
void _StreamCleanup ( PaWasapiStream stream)
void _StreamFinish ( PaWasapiStream stream)
void _StreamOnStop ( PaWasapiStream stream)
UINT32 ALIGN_NEXT_POW2 ( UINT32  v)
typedef BOOL ( WINAPI *  FAvRtCreateThreadOrderingGroup)

Referenced by ProcThreadEvent(), and ProcThreadPoll().

typedef HANDLE ( WINAPI *  FAvSetMmThreadCharacteristics)
HRESULT MarshalStreamComPointers ( PaWasapiStream stream)
HRESULT MarshalSubStreamComPointers ( PaWasapiSubStream substream)
HANDLE MMCSS_activate ( const char *  name)
void MMCSS_deactivate ( HANDLE  hTask)
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 ( 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)
void PaWasapi_FreeMemory ( void *  ptr)
int PaWasapi_GetDeviceDefaultFormat ( void *  pFormat,
unsigned int  nFormatSize,
PaDeviceIndex  nDevice 
)

Returns default sound format for device. Format is represented by PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure.

Parameters
pFormatPointer to PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure.
nFormatSizeSize of PaWinWaveFormat or WAVEFORMATEXTENSIBLE structure in bytes.
nDeviceDevice index.
Returns
Non-negative value indicating the number of bytes copied into format decriptor or, a PaErrorCode (which are always negative) if PortAudio is not initialized or an error is encountered.

References PaWasapiDeviceInfo::DefaultFormat, PaWasapiHostApiRepresentation::deviceCount, PaWasapiHostApiRepresentation::devInfo, PaWasapiHostApiRepresentation::inheritedHostApiRep, paBadBufferPtr, paBufferTooSmall, paInvalidDevice, paNoError, and PaUtil_DeviceIndexToHostApiDeviceIndex().

int PaWasapi_GetDeviceRole ( PaDeviceIndex  nDevice)

Returns device role (PaWasapiDeviceRole enum).

Parameters
nDevicedevice index.
Returns
Non-negative value indicating device role or, a PaErrorCode (which are always negative) if PortAudio is not initialized or an error is encountered.

References PaWasapiHostApiRepresentation::deviceCount, PaWasapiHostApiRepresentation::devInfo, PaWasapiDeviceInfo::formFactor, PaWasapiHostApiRepresentation::inheritedHostApiRep, paInvalidDevice, paNoError, paNotInitialized, and PaUtil_DeviceIndexToHostApiDeviceIndex().

PaError PaWasapi_GetFramesPerHostBuffer ( PaStream pStream,
unsigned int *  nInput,
unsigned int *  nOutput 
)

Get number of frames per host buffer. This is maximal value of frames of WASAPI buffer which can be locked for operations. Use this method as helper to findout maximal values of inputFrames/outputFrames of PaWasapiHostProcessorCallback.

Parameters
pStreamPointer to PaStream to query.
nInputPointer to variable to receive number of input frames. Can be NULL.
nOutputPointer to variable to receive number of output frames. Can be NULL.
Returns
Error code indicating success or failure.
See Also
PaWasapiHostProcessorCallback

References PaWasapiSubStream::framesPerHostCallback, PaWasapiStream::in, PaWasapiStream::out, paBadStreamPtr, and paNoError.

PaError PaWasapi_GetJackCount ( PaDeviceIndex  nDevice,
int *  jcount 
)

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.

Parameters
nDevicedevice index.
jcountNumber of jacks is returned in this variable
Returns
Error code indicating success or failure
See Also
PaWasapi_GetJackDescription

References PaWasapiDeviceInfo::device, PaWasapiHostApiRepresentation::deviceCount, PaWasapiHostApiRepresentation::devInfo, IF_FAILED_JUMP, PaWasapiHostApiRepresentation::inheritedHostApiRep, LogHostError, paInvalidDevice, paNoError, paNotInitialized, PaUtil_DeviceIndexToHostApiDeviceIndex(), and SAFE_RELEASE.

PaError PaWasapi_GetJackDescription ( PaDeviceIndex  nDevice,
int  jindex,
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.

Parameters
nDevicedevice index.
jindexWhich jack to return information
KSJACK_DESCRIPTIONThis structure filled in on success.
Returns
Error code indicating success or failure
See Also
PaWasapi_GetJackCount

References PaWasapiJackDescription::channelMapping, KSJACK_DESCRIPTION::ChannelMapping, PaWasapiJackDescription::color, KSJACK_DESCRIPTION::Color, PaWasapiJackDescription::connectionType, KSJACK_DESCRIPTION::ConnectionType, PaWasapiDeviceInfo::device, PaWasapiHostApiRepresentation::deviceCount, PaWasapiHostApiRepresentation::devInfo, PaWasapiJackDescription::genLocation, KSJACK_DESCRIPTION::GenLocation, PaWasapiJackDescription::geoLocation, KSJACK_DESCRIPTION::GeoLocation, IF_FAILED_JUMP, PaWasapiHostApiRepresentation::inheritedHostApiRep, PaWasapiJackDescription::isConnected, KSJACK_DESCRIPTION::IsConnected, LogHostError, paInvalidDevice, paNoError, paNotInitialized, PaUtil_DeviceIndexToHostApiDeviceIndex(), PaWasapiJackDescription::portConnection, KSJACK_DESCRIPTION::PortConnection, and SAFE_RELEASE.

PaError PaWasapi_Initialize ( PaUtilHostApiRepresentation **  hostApi,
PaHostApiIndex  index 
)

References PaWasapiHostApiRepresentation::allocations, PaWasapiHostApiRepresentation::blockingStreamInterface, PaWasapiHostApiRepresentation::callbackStreamInterface, PaWasapiHostApiRepresentation::defaultCapturer, PaWasapiDeviceInfo::DefaultDevicePeriod, PaWasapiDeviceInfo::DefaultFormat, PaDeviceInfo::defaultHighInputLatency, PaDeviceInfo::defaultHighOutputLatency, PaDeviceInfo::defaultLowInputLatency, PaDeviceInfo::defaultLowOutputLatency, PaWasapiHostApiRepresentation::defaultRenderer, PaDeviceInfo::defaultSampleRate, PaWasapiDeviceInfo::device, DEVICE_STATE_ACTIVE, PaWasapiHostApiRepresentation::deviceCount, PaWasapiHostApiRepresentation::devInfo, E_NOTFOUND, eAll, eCapture, eMultimedia, PaWasapiHostApiRepresentation::enumerator, eRender, PaWasapiDeviceInfo::flow, PaWasapiDeviceInfo::formFactor, GetStreamReadAvailable(), GetStreamWriteAvailable(), PaDeviceInfo::hostApi, IF_FAILED_INTERNAL_ERROR_JUMP, PaUtilHostApiRepresentation::info, PaWasapiHostApiRepresentation::inheritedHostApiRep, LogHostError, MAX_STR_LEN, PaDeviceInfo::maxInputChannels, PaDeviceInfo::maxOutputChannels, PaWasapiDeviceInfo::MinimumDevicePeriod, PaDeviceInfo::name, PA_DEBUG, Pa_GetErrorText(), paInsufficientMemory, paInternalError, paNoDevice, paNoError, paUnanticipatedHostError, PaUtil_AllocateMemory(), PaUtil_CreateAllocationGroup(), PaUtil_DummyGetCpuLoad(), PaUtil_DummyGetReadAvailable(), PaUtil_DummyGetWriteAvailable(), PaUtil_DummyRead(), PaUtil_DummyWrite(), PaUtil_GroupAllocateMemory(), PaUtil_InitializeStreamInterface(), paWASAPI, PRINT, PropVariantClear(), PropVariantInit, ReadStream(), SAFE_RELEASE, PaWasapiDeviceInfo::state, PaHostApiInfo::structVersion, PaDeviceInfo::structVersion, PaWasapiDeviceInfo::szDeviceID, TRUE, PaWasapiHostApiRepresentation::useWOW64Workaround, and WriteStream().

void * PaWasapi_ReallocateMemory ( void *  ptr,
size_t  size 
)
PaError PaWasapi_ThreadPriorityBoost ( void **  hTask,
PaWasapiThreadPriority  nPriorityClass 
)

Boost thread priority of calling thread (MMCSS). Use it for Blocking Interface only for thread which makes calls to Pa_WriteStream/Pa_ReadStream.

Parameters
hTaskHandle to pointer to priority task. Must be used with PaWasapi_RevertThreadPriority method to revert thread priority to initial state.
nPriorityClassId of thread priority of PaWasapiThreadPriority type. Specifying eThreadPriorityNone does nothing.
Returns
Error code indicating success or failure.
See Also
PaWasapi_RevertThreadPriority

References MMCSS_activate(), paNoError, paUnanticipatedHostError, and STATIC_ARRAY_SIZE.

Referenced by ProcThreadEvent(), and ProcThreadPoll().

PaError PaWasapi_ThreadPriorityRevert ( void *  hTask)

Boost thread priority of calling thread (MMCSS). Use it for Blocking Interface only for thread which makes calls to Pa_WriteStream/Pa_ReadStream.

Parameters
hTaskTask handle obtained by PaWasapi_BoostThreadPriority method.
Returns
Error code indicating success or failure.
See Also
PaWasapi_BoostThreadPriority

References MMCSS_deactivate(), paNoError, and paUnanticipatedHostError.

Referenced by _StreamOnStop().

HRESULT ProcessInputBuffer ( PaWasapiStream stream,
PaWasapiHostProcessor processor 
)
HRESULT ProcessOutputBuffer ( PaWasapiStream stream,
PaWasapiHostProcessor processor,
UINT32  frames 
)
PA_THREAD_FUNC ProcThreadEvent ( void *  param)
PA_THREAD_FUNC ProcThreadPoll ( void *  param)
void ReleaseUnmarshaledComPointers ( PaWasapiStream stream)
void ReleaseUnmarshaledSubComPointers ( PaWasapiSubStream substream)
HRESULT UnmarshalStreamComPointers ( PaWasapiStream stream)
HRESULT UnmarshalSubStreamComPointers ( PaWasapiSubStream substream)

Variable Documentation

typedef LPDWORD
FAvRevertMmThreadCharacteristics pAvRevertMmThreadCharacteristics = NULL

Referenced by MMCSS_deactivate().

FAvRtCreateThreadOrderingGroup pAvRtCreateThreadOrderingGroup = NULL
FAvRtDeleteThreadOrderingGroup pAvRtDeleteThreadOrderingGroup = NULL
FAvRtWaitOnThreadOrderingGroup pAvRtWaitOnThreadOrderingGroup = NULL
FAvSetMmThreadCharacteristics pAvSetMmThreadCharacteristics = NULL

Referenced by MMCSS_activate().

FAvSetMmThreadPriority pAvSetMmThreadPriority = NULL