Add stable suffixes to enumerated device names
Compared with cae4a04:
- Append a one-based numeric suffix to every device name returned by gvfg_enumerate_devices so otherwise identical capture devices remain distinguishable in upper-layer selectors.
- Truncate the original display name when necessary so the suffix and null terminator always fit within the fixed public name buffer.
- Preserve the existing fallback name and device enumeration count behavior.
Validation: git diff --check and focused source inspection passed. No configure, build, runtime enumeration, capture, or hardware validation was run for this change.
This commit is contained in:
@@ -1097,6 +1097,14 @@ extern "C"
|
||||
sizeof(out_devices[i].name));
|
||||
if (!out_devices[i].name[0])
|
||||
copy_cstr(out_devices[i].name, sizeof(out_devices[i].name), "GVFG Capture");
|
||||
|
||||
const std::string suffix = " #" + std::to_string(i + 1);
|
||||
std::string displayName = out_devices[i].name;
|
||||
const size_t maxNameLength = sizeof(out_devices[i].name) - 1;
|
||||
if (displayName.size() + suffix.size() > maxNameLength)
|
||||
displayName.resize(maxNameLength - suffix.size());
|
||||
displayName += suffix;
|
||||
copy_cstr(out_devices[i].name, sizeof(out_devices[i].name), displayName.c_str());
|
||||
}
|
||||
return written;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user