Commit 51278484 authored by dmitrykos's avatar dmitrykos

wasapi: workaround to avoid PaWasapi_Initialize() failure when enumerating…

wasapi: workaround to avoid PaWasapi_Initialize() failure when enumerating devices and device fails to report min/default periods with IAudioClient::GetDevicePeriod(): ignore error and assign WASAPI common known period values for min/default

git-svn-id: https://subversion.assembla.com/svn/portaudio/portaudio/trunk@1962 0f58301d-fd10-0410-b4af-bbb618454e57
parent a636171e
......@@ -1283,6 +1283,11 @@ PaError PaWasapi_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
paWasapi->devInfo = (PaWasapiDeviceInfo *)PaUtil_AllocateMemory(sizeof(PaWasapiDeviceInfo) * paWasapi->deviceCount);
if (paWasapi->devInfo == NULL)
{
result = paInsufficientMemory;
goto error;
}
for (i = 0; i < paWasapi->deviceCount; ++i)
memset(&paWasapi->devInfo[i], 0, sizeof(PaWasapiDeviceInfo));
......@@ -1446,9 +1451,14 @@ PaError PaWasapi_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
hr = IAudioClient_GetDevicePeriod(tmpClient,
&paWasapi->devInfo[i].DefaultDevicePeriod,
&paWasapi->devInfo[i].MinimumDevicePeriod);
// We need to set the result to a value otherwise we will return paNoError
// [IF_FAILED_JUMP(hResult, error);]
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
if (FAILED(hr))
{
PA_DEBUG(("WASAPI:%d| failed getting min/default periods by IAudioClient::GetDevicePeriod() with error[%d], will use 30000/100000 hns\n", i));
// assign WASAPI common values
paWasapi->devInfo[i].DefaultDevicePeriod = 100000;
paWasapi->devInfo[i].MinimumDevicePeriod = 30000;
}
//hr = tmpClient->GetMixFormat(&paWasapi->devInfo[i].MixFormat);
......@@ -1492,7 +1502,7 @@ PaError PaWasapi_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd
// We need to set the result to a value otherwise we will return paNoError
result = paInternalError;
//continue; // do not skip from list, allow to initialize
break;
break;
}
(*hostApi)->deviceInfos[i] = deviceInfo;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment