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.
This commit is contained in:
parent
b19ea6fe35
commit
21737d5f7a
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user