From 3bb7587c5d0bb348c1aa685ee4c91b58f54b8696 Mon Sep 17 00:00:00 2001 From: Daan van Hasselt Date: Wed, 26 Oct 2016 03:16:45 +0200 Subject: [PATCH 1/2] dont use CHECK_HR in audio device enumeration loop use continue instead. this way if one device fails, the rest of the devices still get a chance --- KCBv2/KCBv2Lib.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/KCBv2/KCBv2Lib.cpp b/KCBv2/KCBv2Lib.cpp index 842f7b1..c00684a 100644 --- a/KCBv2/KCBv2Lib.cpp +++ b/KCBv2/KCBv2Lib.cpp @@ -104,17 +104,27 @@ HRESULT FindAudioDevice(const WCHAR* wsName, IAudioClient** ppClient) // Each loop until we find the Kinect USB Audio device for (ULONG i = 0; i < count; ++i) { - CHECK_HR(hr = pCollection->Item(i, &pEndpoint)); + hr = pCollection->Item(i, &pEndpoint); + if (!SUCCEEDED(hr)) { + continue; + } // get the property store from the device - CHECK_HR(hr = pEndpoint->OpenPropertyStore(STGM_READ, &pProps)); + hr = pEndpoint->OpenPropertyStore(STGM_READ, &pProps); + if (!SUCCEEDED(hr)) { + continue; + } // Initialize container for property value. PROPVARIANT varName; PropVariantInit(&varName); // Get the endpoint's friendly-name property. - CHECK_HR(hr = pProps->GetValue(PKEY_Device_FriendlyName, &varName)); + hr = pProps->GetValue(PKEY_Device_FriendlyName, &varName); + + if (!SUCCEEDED(hr)) { + continue; + } // get the name from the property store name = varName.pwszVal; From a78bf60b6d5ab35576375a847d767885b7e43221 Mon Sep 17 00:00:00 2001 From: Daan van Hasselt Date: Wed, 26 Oct 2016 03:17:17 +0200 Subject: [PATCH 2/2] fixed reading audio data from audioStream i assume this was a typo, since it was always reading only 4 bytes --- KCBv2/KCBSensor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/KCBv2/KCBSensor.cpp b/KCBv2/KCBSensor.cpp index 2ec7736..a5b20c3 100644 --- a/KCBv2/KCBSensor.cpp +++ b/KCBv2/KCBSensor.cpp @@ -900,7 +900,7 @@ HRESULT KCBSensor::GetAudioBuffer(ULONG cb, _Out_writes_bytes_to_(cb, *pcbRead) SAFE_RELEASE(pAudioBeam); } - CHECK_HR(hr = m_pAudioStream->Read((void *)cbBuffer, sizeof(cb), pcbRead)); + CHECK_HR(hr = m_pAudioStream->Read((void *)cbBuffer, cb, pcbRead)); if (*pcbRead > 0) {