提交 21737d5f 编写于 作者: R Richard Stanway

win-wasapi: Fix crash on certain devices

Not all devices return PKEY_AudioEngine_DeviceFormat properties.

Per MSDN, if the PROPERTYKEY referenced in key is not present in
the property store, this method returns S_OK and the vt member of
the structure pointed to by pv is set to VT_EMPTY.
上级 b19ea6fe
......@@ -319,10 +319,12 @@ void WASAPISource::Initialize()
resSample =
store->GetValue(PKEY_AudioEngine_DeviceFormat, &prop);
if (!FAILED(resSample)) {
deviceFormatProperties =
(PWAVEFORMATEX)prop.blob.pBlobData;
device_sample = std::to_string(
deviceFormatProperties->nSamplesPerSec);
if (prop.vt != VT_EMPTY && prop.blob.pBlobData) {
deviceFormatProperties =
(PWAVEFORMATEX)prop.blob.pBlobData;
device_sample = std::to_string(
deviceFormatProperties->nSamplesPerSec);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册