Use GetMixFormat() instead of PKEY_AudioEngine_DeviceFormat.
See #286 for rationale.
This commit is contained in:
parent
0bb476d8dc
commit
1f5429ee43
1 changed files with 18 additions and 13 deletions
|
|
@ -1790,19 +1790,6 @@ static PaError CreateDeviceList(PaWasapiHostApiRepresentation *paWasapi, PaHostA
|
||||||
PA_DEBUG(("WASAPI:%d| name[%s]\n", i, deviceInfo->name));
|
PA_DEBUG(("WASAPI:%d| name[%s]\n", i, deviceInfo->name));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Default format
|
|
||||||
{
|
|
||||||
PROPVARIANT value;
|
|
||||||
PropVariantInit(&value);
|
|
||||||
hr = IPropertyStore_GetValue(pProperty, &PKEY_AudioEngine_DeviceFormat, &value);
|
|
||||||
// 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);
|
|
||||||
memcpy(&paWasapi->devInfo[i].DefaultFormat, value.blob.pBlobData, min(sizeof(paWasapi->devInfo[i].DefaultFormat), value.blob.cbSize));
|
|
||||||
// cleanup
|
|
||||||
PropVariantClear(&value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Formfactor
|
// Formfactor
|
||||||
{
|
{
|
||||||
PROPVARIANT value;
|
PROPVARIANT value;
|
||||||
|
|
@ -1855,6 +1842,24 @@ static PaError CreateDeviceList(PaWasapiHostApiRepresentation *paWasapi, PaHostA
|
||||||
// [IF_FAILED_JUMP(hResult, error);]
|
// [IF_FAILED_JUMP(hResult, error);]
|
||||||
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
|
IF_FAILED_INTERNAL_ERROR_JUMP(hr, result, error);
|
||||||
|
|
||||||
|
// Get the default format.
|
||||||
|
//
|
||||||
|
// Note: this is using IAudioClient::GetMixFormat(), not
|
||||||
|
// PKEY_AudioEngine_DeviceFormat, because the latter has been shown to
|
||||||
|
// be unreliable - see:
|
||||||
|
// https://app.assembla.com/spaces/portaudio/tickets/286
|
||||||
|
// The downside of using GetMixFormat() is that the sample type reported
|
||||||
|
// by PaWasapi_GetDeviceDefaultFormat() will always be 32-bit float.
|
||||||
|
// That seems fine since PortAudio will automatically do any required
|
||||||
|
// conversions.
|
||||||
|
WAVEFORMATEXTENSIBLE *format;
|
||||||
|
hr = IAudioClient_GetMixFormat(tmpClient, &format);
|
||||||
|
if (SUCCEEDED(hr))
|
||||||
|
{
|
||||||
|
memcpy(&paWasapi->devInfo[i].DefaultFormat, format, sizeof(*format));
|
||||||
|
CoTaskMemFree(format);
|
||||||
|
}
|
||||||
|
|
||||||
// Get latency
|
// Get latency
|
||||||
hr = IAudioClient_GetDevicePeriod(tmpClient,
|
hr = IAudioClient_GetDevicePeriod(tmpClient,
|
||||||
&paWasapi->devInfo[i].DefaultDevicePeriod,
|
&paWasapi->devInfo[i].DefaultDevicePeriod,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue