IMMDeviceEnumerator *enumerator;\r
\r
//this is the REAL number of devices, whether they are usefull to PA or not!\r
- UINT deviceCount;\r
+ UINT32 deviceCount;\r
\r
WCHAR defaultRenderer [MAX_STR_LEN];\r
WCHAR defaultCapturer [MAX_STR_LEN];\r
\r
if (paWasapi->deviceCount > 0)\r
{\r
- (*hostApi)->deviceInfos = (PaDeviceInfo**)PaUtil_GroupAllocateMemory(\r
- paWasapi->allocations, sizeof(PaDeviceInfo*) * paWasapi->deviceCount);\r
- if (!(*hostApi)->deviceInfos)\r
+ (*hostApi)->deviceInfos = (PaDeviceInfo **)PaUtil_GroupAllocateMemory(\r
+ paWasapi->allocations, sizeof(PaDeviceInfo *) * paWasapi->deviceCount);\r
+ if ((*hostApi)->deviceInfos == NULL)\r
{\r
result = paInsufficientMemory;\r
goto error;\r
}\r
\r
/* allocate all device info structs in a contiguous block */\r
- deviceInfoArray = (PaDeviceInfo*)PaUtil_GroupAllocateMemory(\r
+ deviceInfoArray = (PaDeviceInfo *)PaUtil_GroupAllocateMemory(\r
paWasapi->allocations, sizeof(PaDeviceInfo) * paWasapi->deviceCount);\r
- if (!deviceInfoArray)\r
+ if (deviceInfoArray == NULL)\r
{\r
result = paInsufficientMemory;\r
goto error;\r
}\r
\r
// ------------------------------------------------------------------------------------------\r
-static PaWasapiHostApiRepresentation *GetHostApi(PaError *_error)\r
+static PaWasapiHostApiRepresentation *_GetHostApi(PaError *_error)\r
{\r
PaError error;\r
\r
PaError ret;\r
PaWasapiHostApiRepresentation *paWasapi;\r
UINT32 size;\r
+ PaDeviceIndex index;\r
\r
if (pFormat == NULL)\r
return paBadBufferPtr;\r
return paBufferTooSmall;\r
\r
// Get API\r
- paWasapi = GetHostApi(&ret);\r
+ paWasapi = _GetHostApi(&ret);\r
if (paWasapi == NULL)\r
return ret;\r
\r
- if ((UINT32)nDevice >= paWasapi->deviceCount)\r
+ // Get device index\r
+ ret = PaUtil_DeviceIndexToHostApiDeviceIndex(&index, nDevice, &paWasapi->inheritedHostApiRep);\r
+ if (ret != paNoError)\r
+ return ret;\r
+\r
+ // Validate index\r
+ if ((UINT32)index >= paWasapi->deviceCount)\r
return paInvalidDevice;\r
\r
- size = min(nFormatSize, (UINT32)sizeof(paWasapi->devInfo[ nDevice ].DefaultFormat));\r
- memcpy(pFormat, &paWasapi->devInfo[ nDevice ].DefaultFormat, size);\r
+ size = min(nFormatSize, (UINT32)sizeof(paWasapi->devInfo[ index ].DefaultFormat));\r
+ memcpy(pFormat, &paWasapi->devInfo[ index ].DefaultFormat, size);\r
\r
return size;\r
}\r
int PaWasapi_GetDeviceRole( PaDeviceIndex nDevice )\r
{\r
PaError ret;\r
+ PaDeviceIndex index;\r
\r
// Get API\r
- PaWasapiHostApiRepresentation *paWasapi = GetHostApi(&ret);\r
+ PaWasapiHostApiRepresentation *paWasapi = _GetHostApi(&ret);\r
if (paWasapi == NULL)\r
return ret;\r
\r
- if (nDevice >= (int)paWasapi->deviceCount)\r
+ // Get device index\r
+ ret = PaUtil_DeviceIndexToHostApiDeviceIndex(&index, nDevice, &paWasapi->inheritedHostApiRep);\r
+ if (ret != paNoError)\r
+ return ret;\r
+\r
+ // Validate index\r
+ if ((UINT32)index >= paWasapi->deviceCount)\r
return paInvalidDevice;\r
\r
- return paWasapi->devInfo[ nDevice ].formFactor;\r
+ return paWasapi->devInfo[ index ].formFactor;\r
}\r
\r
// ------------------------------------------------------------------------------------------\r