Closed Ivan-Grebennikov closed 1 year ago
Happy to merge this, but wondering if maybe we should just set the unique name to the friendly name if no unique name exists?
Maybe more useful than an empty string?
I think it would be the great decision!
Have made neccesary changes.
Great - thank you @Ivan-Grebennikov!
Hi, @ofTheo!
The issue is - even if "FriendlyName" query fails
deviceCounter
is increased, butdeviceUniqueNames
size remains the same - so we could face an index mismatch for the same device in the two arrays.The solution is we should add string to
deviceUniqueNames
array regardless of "FriendlyName" query status.deviceNames
is a vector of FriendlyNames and is initialized with 255 empty strings:https://github.com/ofTheo/videoInput/blob/870dbabda79470736e5d5294038ae5676ebb238a/videoInputSrcAndDemos/libs/videoInput/videoInput.cpp#L770
So we have initially 255 devices whose FriendlyNames are updated after
listDevices()
is called. And we just skip device indeviceNames
if FriendlyName query is failed leaving it empty, butdeviceUniqueNames
size is not increased for this device, and we have index mismatch, and the methods:https://github.com/ofTheo/videoInput/blob/870dbabda79470736e5d5294038ae5676ebb238a/videoInputSrcAndDemos/libs/videoInput/videoInput.cpp#L786
and
https://github.com/ofTheo/videoInput/blob/870dbabda79470736e5d5294038ae5676ebb238a/videoInputSrcAndDemos/libs/videoInput/videoInput.cpp#L812
may not return same index for the same device afterwards.