Merge pull request #26034 from Octopus136:issue-26033

Fix: reduce redundant code by optimizing device name retrieval
pull/26045/head
Alexander Smorkalov 3 months ago committed by GitHub
commit ae4a11b0c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      modules/videoio/src/cap_dshow.cpp

@ -1382,14 +1382,11 @@ int videoInput::listDevices(bool silent){
// Find the description or friendly name.
VARIANT varName;
VariantInit(&varName);
hr = pPropBag->Read(L"Description", &varName, 0);
hr = pPropBag->Read(L"FriendlyName", &varName, 0);
if (FAILED(hr)) hr = pPropBag->Read(L"FriendlyName", &varName, 0);
if (FAILED(hr)) hr = pPropBag->Read(L"Description", &varName, 0);
if (SUCCEEDED(hr)){
hr = pPropBag->Read(L"FriendlyName", &varName, 0);
int count = 0;
int maxLen = sizeof(deviceNames[0])/sizeof(deviceNames[0][0]) - 2;
while( varName.bstrVal[count] != 0x00 && count < maxLen) {

Loading…
Cancel
Save