Bring PS5 GTA6 to 120FPS with DLSS 5. An advanced Windows video player and capture enhancement tool featuring real-time preview for videos, images, and capture card sources. Combine AI-powered Super Resolution, DLSS5 image enhancement, and Frame Generation to deliver a next-generation visual experience.
C++
fix(audio): identify the AVerMedia card from the device tree, not the DirectShow path
Veyra Goal Agented43d711574f
diff --git a/docs/AVERMEDIA_5P1_SWITCH_IMPLEMENTATION_2026-09-17.md b/docs/AVERMEDIA_5P1_SWITCH_IMPLEMENTATION_2026-09-17.mdindex eb966768..faad7a40 100644--- a/docs/AVERMEDIA_5P1_SWITCH_IMPLEMENTATION_2026-09-17.md+++ b/docs/AVERMEDIA_5P1_SWITCH_IMPLEMENTATION_2026-09-17.md@@ -236,3 +236,74 @@ PASS (0 failures)未提交任何 SDK / DLL / 模型 / 用户配置;`third_party_local`、`runtime_local`、`loop\local` 在隔离 worktree 里是**目录联接**(只读复用主检出的本地依赖),不参与版本控制。++---++## 附录 C:用户实测日志复盘(2026-09-17)与修复++日志:`veyra-app(8).log`(1,472,697 字节,4104 行,SHA256 待补),隔离测试包第一次真机运行。++### C1 结论:这次**没有测到功能**,是我的识别逻辑把它挡在门外++日志里 6 次 DirectShow 连接全部是同一行:++```+[capture-audio-vendor] skipped: not an AVerMedia capture device (device="")+```++`device=""` 是空的——同时那行 `binding=separate ... device="0040..."` 打出来的是一串十六进制。+解码后是:++```+@device:cm:{33D9A762-90C8-11D0-BD43-00A0C911CE86}\wave:{C25BCE96-8C5E-4894-8ED1-092A0D29FDA5}+```++即 `pathTag(selection.audioPath)`:**这张卡音频设备的 DirectShow moniker 根本没有 `DevicePath` 属性**,+Veyra 保存下来的是类管理器显示名,里面没有 `vid_07ca`。而开关的准入条件恰恰是"路径含 vid_07ca",+于是 6 次全部直接跳过——**开关一次都没发出去**,`device bitstream types=0` 和+`no IEC 61937 burst` 都只是"没切"的自然结果。++顺带两处自曝的毛病:+1. 那行 `binding=separate` 的格式串只有 3 个占位符却传了 4 个参数,`device=` 打的是路径而不是友好名+ (我上一轮想加的"设备名进日志"实际没生效);`audioPathTag=0` 也是历史遗留的错位参数。+2. 因为准入失败,日志里连"组件装没装"都没记录。++### C2 这次实测仍然提供了三条有价值的事实++1. **音频设备确实是那张卡**:枚举出 15 个 PCM 媒体类型(含 8 位 / 11.025k / 8k)+ 48k/96k,+ 与本机 GC553G2 的指纹完全一致(索引 0 和索引 2 各一个,指纹相同)。+2. **声音是真的**:多个会话峰值 0.17–0.33(11:07 那次到 0.81),说明游戏音频正常送达,+ 不是静音、也不是位流当 PCM 的噪音。+3. **用户把三种接法都试了**:DirectShow 独立设备、WASAPI(-3)、以及视频设备内置音频;+ DirectShow 与 WASAPI 都能出声音,行为与预期一致。++### C3 修复++1. **不再依赖 DirectShow 路径识别设备**:新增 `AverMediaAudioSwitch::findUsbFunctions()`,+ 用 SetupAPI 按 `KSCATEGORY_AUDIO` / `KSCATEGORY_CAPTURE` 枚举设备接口,挑出 `VID_07CA` 的+ USB 功能,把**真实接口路径**(`\\?\usb#vid_07ca&pid_2553&mi_02#...#{guid}`)喂给厂商组件——+ 它本来就只从路径里抠 `vid_`/`&pid_` 两个 token,拿不出这两个 token 就什么都做不了。+ 接口类枚举失败时退化为实例 ID(小写化、反斜杠转 `#`),仍然带得住这两个 token。+ 所有候选(实例 ID / 友好名 / 接口路径)都进日志。+2. **修好设备名日志**:格式串与参数对齐,`binding=separate` 现在打印真正的 DirectShow 友好名+ (stable 路径与序号两种形式都解析)。+3. **组件状态永远可见**:即使设备识别失败,日志也会写出设备树里找到了什么。++### C4 本机验证++```+veyra_avermedia_switch_tests:PASS(0 失败)+ note vid_07ca functions on this machine: 0 ← 本机没插卡,符合预期+ note vid_ devices on this machine: 2+ note of those: interfacePath=2 friendlyName=2 ← 接口类枚举确实拿到真实路径+ ok every path handed to the vendor carries the vendor token+ ok the composite audio function is preferred over the camera functions+delivery 短测:PASS(logs\delivery\ac2283ab2a9d4f9e90738120ad79aada\result.json)+```++### C5 环境坑(记录一次,避免重复踩)++隔离 worktree 最初把 `runtime_local` 做成了指向主检出的**目录联接**。`applicationRoot()` 会从 exe+往上找到第一个含 `runtime_local` 的目录,于是两个会话**共用同一份 UI 设置/预设**:门禁里的+`--smoke-color` 因此出现一次假失败(共享状态漂移),改成"只硬链接运行库、不共享状态文件"后复跑+PASS。隔离工作区可以共享二进制依赖,**不能共享状态**。diff --git a/include/veyra/source/AverMediaAudioSwitch.h b/include/veyra/source/AverMediaAudioSwitch.hindex c315187f..7b6a7df4 100644--- a/include/veyra/source/AverMediaAudioSwitch.h+++ b/include/veyra/source/AverMediaAudioSwitch.h@@ -29,11 +29,26 @@#include <memory>#include <string>#include <string_view>+#include <vector>namespace veyra::source {enum class AverMediaSwitchState { Unavailable, Ready, Switched, Failed };+// One AVerMedia USB function as Windows sees it in the device tree.+//+// This exists because the DirectShow audio moniker of these cards does not+// always carry a DevicePath: on the machine that produced the 2026-09-17 field+// log the stored path was the class-manager display name+// ("@device:cm:{...}\wave:{...}"), which contains no vid_/pid_ at all, while+// the vendor component parses exactly those out of the path. The device tree+// still knows the truth.+struct AverMediaUsbFunction {+ std::wstring instanceId; // USB\VID_07CA&PID_2553&MI_02\5&2f0a1c4&0&0002+ std::wstring friendlyName; // driver friendly name, may be empty+ std::wstring interfacePath; // \\?\usb#vid_07ca&pid_2553&mi_02#...#{guid}+};+struct AverMediaSwitchStatus {AverMediaSwitchState state = AverMediaSwitchState::Unavailable;bool componentFound = false;@@ -58,6 +73,16 @@ public:// Cheap test used to skip unrelated audio devices: the DirectShow device// path of an AVerMedia capture device carries vid_07ca.static bool isAverMediaDevicePath(std::wstring_view devicePath);+ // Every present USB function whose device instance id contains+ // `vendorToken` (production uses L"vid_07ca"). Enumerated from the device+ // tree, so it works when DirectShow gives us nothing usable. `vendorToken`+ // is a parameter so tests can prove the enumeration itself works on a+ // machine that has no AVerMedia hardware.+ static std::vector<AverMediaUsbFunction> findUsbFunctions(std::wstring_view vendorToken);+ // Picks the audio function out of a device-tree result: the UAC interface+ // is the one Windows exposes as an audio endpoint. Falls back to the only+ // entry when there is exactly one.+ static const AverMediaUsbFunction* pickAudioFunction(const std::vector<AverMediaUsbFunction>& functions);// Loads the component (once) and arms non-PCM passthrough for the card// behind `devicePath`. Never throws; failures are reported in status().diff --git a/src/source/AverMediaAudioSwitch.cpp b/src/source/AverMediaAudioSwitch.cppindex 2fee2d91..e165f469 100644--- a/src/source/AverMediaAudioSwitch.cpp+++ b/src/source/AverMediaAudioSwitch.cpp@@ -3,15 +3,56 @@#include "veyra/Log.h"#include <windows.h>+#include <setupapi.h>#include <cstdint>#include <format>#include <string>#include <vector>+#pragma comment(lib, "setupapi.lib")+namespace veyra::source {namespace {+bool containsCaseInsensitive(std::wstring_view haystack, std::wstring_view needle) {+ if (needle.empty() || haystack.size() < needle.size()) return false;+ for (size_t start = 0; start + needle.size() <= haystack.size(); ++start) {+ bool match = true;+ for (size_t i = 0; i < needle.size(); ++i) {+ if (towlower(haystack[start + i]) != towlower(needle[i])) { match = false; break; }+ }+ if (match) return true;+ }+ return false;+}++std::wstring deviceProperty(HDEVINFO set, SP_DEVINFO_DATA* info, DWORD property) {+ wchar_t buffer[1024] = {};+ DWORD type = 0;+ DWORD bytes = 0;+ if (!SetupDiGetDeviceRegistryPropertyW(set, info, property, &type, reinterpret_cast<BYTE*>(buffer), sizeof(buffer), &bytes)) return {};+ if (type != REG_SZ && type != REG_EXPAND_SZ) return {};+ return std::wstring(buffer, bytes / sizeof(wchar_t) > 0 ? (bytes / sizeof(wchar_t)) - 1 : 0);+}++// Device interface classes that carry the real "\\?\usb#vid_...#{guid}" path a+// USB audio function is reached by. Declared locally so this translation unit+// does not need INITGUID (which would leak definitions into other TUs).+constexpr GUID kCategoryAudio = {0x6994AD04, 0x93EF, 0x11D0, {0xA3, 0xCC, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};+constexpr GUID kCategoryCapture = {0x65E8773D, 0x8F56, 0x11D0, {0xA3, 0xB9, 0x00, 0xA0, 0xC9, 0x22, 0x31, 0x96}};++// Lower-case display-name form the vendor parser expects: it looks for the+// literal tokens "vid_" and "&pid_", so an upper-case instance id would never+// match. Used only when no real interface path could be resolved.+std::wstring syntheticInterfacePath(const std::wstring& instanceId) {+ std::wstring lowered;+ lowered.reserve(instanceId.size() + 8);+ for (wchar_t character : instanceId) lowered.push_back(wchar_t(towlower(character)));+ for (wchar_t& character : lowered) if (character == L'\\') character = L'#';+ return L"\\\\?\\" + lowered;+}+// ---------------------------------------------------------------------------// ABI mirror of the component's public headers (GPLv2, shipped in// AVerMedia-Technologies-Inc/obs-MultichannelAudio). Only the layout matters:@@ -301,6 +342,104 @@ bool AverMediaAudioSwitch::isAverMediaDevicePath(std::wstring_view devicePath) {return lowered.find(L"vid_07ca") != std::wstring::npos;}+std::vector<AverMediaUsbFunction> AverMediaAudioSwitch::findUsbFunctions(std::wstring_view vendorToken) {+ std::vector<AverMediaUsbFunction> result;+ if (vendorToken.empty()) return result;+ // Preferred route: enumerate the device interface classes directly. This is+ // what yields the "\\?\usb#vid_...#{guid}" strings the vendor component+ // parses; enumerating interfaces of a class-less device set returns none.+ for (const GUID* category : {&kCategoryAudio, &kCategoryCapture}) {+ HDEVINFO interfaces = SetupDiGetClassDevsW(category, nullptr, nullptr, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);+ if (interfaces == INVALID_HANDLE_VALUE) continue;+ for (DWORD index = 0;; ++index) {+ SP_DEVICE_INTERFACE_DATA interfaceData{};+ interfaceData.cbSize = sizeof(interfaceData);+ if (!SetupDiEnumDeviceInterfaces(interfaces, nullptr, category, index, &interfaceData)) break;+ DWORD required = 0;+ SetupDiGetDeviceInterfaceDetailW(interfaces, &interfaceData, nullptr, 0, &required, nullptr);+ if (required == 0) continue;+ std::vector<BYTE> buffer(required);+ auto* detail = reinterpret_cast<SP_DEVICE_INTERFACE_DETAIL_DATA_W*>(buffer.data());+ detail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W);+ SP_DEVINFO_DATA info{};+ info.cbSize = sizeof(info);+ if (!SetupDiGetDeviceInterfaceDetailW(interfaces, &interfaceData, detail, required, nullptr, &info)) continue;+ wchar_t instance[512] = {};+ if (!SetupDiGetDeviceInstanceIdW(interfaces, &info, instance, 512, nullptr)) continue;+ if (!containsCaseInsensitive(instance, vendorToken)) continue;+ bool duplicate = false;+ for (const auto& existing : result) {+ if (_wcsicmp(existing.instanceId.c_str(), instance) == 0) { duplicate = true; break; }+ }+ if (duplicate) continue;+ AverMediaUsbFunction function;+ function.instanceId = instance;+ function.friendlyName = deviceProperty(interfaces, &info, SPDRP_FRIENDLYNAME);+ function.interfacePath = detail->DevicePath;+ result.push_back(std::move(function));+ if (result.size() > 64) break; // sanity bound+ }+ SetupDiDestroyDeviceInfoList(interfaces);+ }+ if (!result.empty()) return result;+ // Fallback: class-less enumeration, which still gives the instance id (that+ // alone carries vid_/pid_ once lower-cased).+ HDEVINFO set = SetupDiGetClassDevsW(nullptr, nullptr, nullptr, DIGCF_ALLCLASSES | DIGCF_PRESENT);+ if (set == INVALID_HANDLE_VALUE) return result;+ for (DWORD index = 0;; ++index) {+ SP_DEVINFO_DATA info{};+ info.cbSize = sizeof(info);+ if (!SetupDiEnumDeviceInfo(set, index, &info)) break;+ wchar_t instance[512] = {};+ if (!SetupDiGetDeviceInstanceIdW(set, &info, instance, 512, nullptr)) continue;+ if (!containsCaseInsensitive(instance, vendorToken)) continue;+ AverMediaUsbFunction function;+ function.instanceId = instance;+ function.friendlyName = deviceProperty(set, &info, SPDRP_FRIENDLYNAME);+ // No interface class matched: give the vendor parser the lower-cased+ // display-name shape anyway, because it only needs vid_/pid_ from here+ // and re-enumerates the device tree itself afterwards.+ function.interfacePath = syntheticInterfacePath(instance);+ // First interface of this function is enough: the vendor component+ // re-enumerates the device tree itself once it has vid/pid, and it only+ // needs one path that carries them.+ for (DWORD interfaceIndex = 0;; ++interfaceIndex) {+ SP_DEVICE_INTERFACE_DATA interfaceData{};+ interfaceData.cbSize = sizeof(interfaceData);+ if (!SetupDiEnumDeviceInterfaces(set, &info, nullptr, interfaceIndex, &interfaceData)) break;+ DWORD required = 0;+ SetupDiGetDeviceInterfaceDetailW(set, &interfaceData, nullptr, 0, &required, nullptr);+ if (required == 0) continue;+ std::vector<BYTE> buffer(required);+ auto* detail = reinterpret_cast<SP_DEVICE_INTERFACE_DETAIL_DATA_W*>(buffer.data());+ detail->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA_W);+ if (SetupDiGetDeviceInterfaceDetailW(set, &interfaceData, detail, required, nullptr, nullptr)) {+ function.interfacePath = detail->DevicePath;+ break;+ }+ }+ result.push_back(std::move(function));+ }+ SetupDiDestroyDeviceInfoList(set);+ return result;+}++const AverMediaUsbFunction* AverMediaAudioSwitch::pickAudioFunction(const std::vector<AverMediaUsbFunction>& functions) {+ // A UVC/UAC composite puts the audio streaming interface on a later+ // function (mi_00/mi_01 are the camera); prefer that, then an audio-looking+ // friendly name, then the only candidate.+ for (const auto& function : functions) {+ if (containsCaseInsensitive(function.instanceId, L"mi_02")) return &function;+ }+ for (const auto& function : functions) {+ if (containsCaseInsensitive(function.interfacePath, L"audio")) return &function;+ }+ for (const auto& function : functions) {+ if (containsCaseInsensitive(function.friendlyName, L"audio")) return &function;+ }+ return functions.size() == 1 ? &functions.front() : nullptr;+}+bool AverMediaAudioSwitch::apply(const std::wstring& deviceName, const std::wstring& devicePath) {auto& impl = *p_;if (impl.sdkInitialized && !devicePath.empty()) {diff --git a/src/source/CaptureCardSource.cpp b/src/source/CaptureCardSource.cppindex 8064e5ff..90b7397f 100644--- a/src/source/CaptureCardSource.cpp+++ b/src/source/CaptureCardSource.cpp@@ -235,6 +235,11 @@ struct CaptureCardSource::Impl:ISampleGrabberCB {// card downmixes to real 2.0 when passthrough is not armed - only the bytes// tell the two apart. Observational: it never changes what is played.std::shared_ptr<sink::Iec61937Probe> carrierProbe;+ // Friendly name of the DirectShow audio device being connected, resolved+ // before the graph is built. The log has to carry it: the stored path may+ // be an opaque class-manager display name, which made the 2026-09-17 field+ // log impossible to interpret.+ std::wstring pendingAudioName;// AVerMedia GC553G2 / GC553PRO / GC575 only forward compressed HDMI audio// after the installed vendor component arms non-PCM passthrough. The// component is loaded from the user's own OBS installation (never@@ -633,8 +638,14 @@ bool CaptureCardSource::configure(const SourceOpenDesc& desc){close();p_->lastAu// The AVerMedia switch is keyed on the device path, and it has to// happen first so media-type enumeration sees the post-switch state.std::wstring audioName,audioPath;- if(selection.stable)audioPath=selection.audioPath;- else{auto list=monikers(true);if(size_t(audio)<list.size()){audioName=propertyString(list[size_t(audio)].Get(),L"FriendlyName");audioPath=monikerPath(list[size_t(audio)].Get());}}+ auto list=monikers(true);+ for(size_t i=0;i<list.size();++i){+ const std::wstring path=monikerPath(list[i].Get());+ const bool wanted=selection.stable?(path==selection.audioPath):(i==size_t(audio));+ if(!wanted)continue;+ audioName=propertyString(list[i].Get(),L"FriendlyName");audioPath=path;break;+ }+ p.pendingAudioName=audioName;if(!audioPath.empty())applyVendorAudioSwitch(audioName,audioPath);}const bool audioReady=connectDirectShowAudio(desc);@@ -686,19 +697,38 @@ bool CaptureCardSource::configure(const SourceOpenDesc& desc){close();p_->lastAu}bool CaptureCardSource::applyVendorAudioSwitch(const std::wstring& audioName,const std::wstring& audioPath){auto& p=*p_;- if(!AverMediaAudioSwitch::isAverMediaDevicePath(audioPath)){- log::info("capture-audio-vendor",std::format("skipped: not an AVerMedia capture device (device=\"{}\")",narrowForLog(audioName)));- return false;+ std::wstring name=audioName,path=audioPath;+ if(!AverMediaAudioSwitch::isAverMediaDevicePath(path)){+ // These cards' DirectShow audio monikers often carry no DevicePath, so+ // the stored path is the class-manager display name+ // ("@device:cm:{...}\wave:{...}") and contains no vid_/pid_ - exactly+ // the tokens the vendor component parses. Ask the device tree instead:+ // the USB functions are still there.+ const auto functions=AverMediaAudioSwitch::findUsbFunctions(L"vid_07ca");+ for(const auto& function:functions)+ log::info("capture-audio-vendor",std::format("device tree: instance=\"{}\" friendly=\"{}\" interfacePath={}",+ narrowForLog(function.instanceId),narrowForLog(function.friendlyName),+ function.interfacePath.empty()?std::string("<none>"):pathTag(function.interfacePath)));+ const auto* chosen=AverMediaAudioSwitch::pickAudioFunction(functions);+ if(chosen==nullptr){+ log::info("capture-audio-vendor",std::format("skipped: no AVerMedia USB audio function present (selected device=\"{}\" directShowPath={})",+ narrowForLog(name),pathTag(path)));+ return false;+ }+ if(name.empty())name=chosen->friendlyName;+ path=chosen->interfacePath.empty()?chosen->instanceId:chosen->interfacePath;+ log::info("capture-audio-vendor",std::format("using device-tree audio function instance=\"{}\" for selected device=\"{}\"",+ narrowForLog(chosen->instanceId),narrowForLog(name)));}- const bool applied=p.averMediaSwitch.apply(audioName,audioPath);+ const bool applied=p.averMediaSwitch.apply(name,path);const auto& status=p.averMediaSwitch.status();if(applied){log::info("capture-audio-vendor",std::format("non-PCM switch armed device=\"{}\" component=\"{}\" chipFormat={} nonPcmNow={} monitoring={}",- narrowForLog(audioName),narrowForLog(status.componentRoot),status.chipAudioFormat,status.nonPcmActive?1:0,+ narrowForLog(name),narrowForLog(status.componentRoot),status.chipAudioFormat,status.nonPcmActive?1:0,p.averMediaSwitch.active()?1:0));}else{log::warn("capture-audio-vendor",std::format("non-PCM switch unavailable device=\"{}\" componentFound={} dllsLoaded={} detail=\"{}\"",- narrowForLog(audioName),status.componentFound?1:0,status.dllsLoaded?1:0,status.detail));+ narrowForLog(name),status.componentFound?1:0,status.dllsLoaded?1:0,status.detail));}return applied;}@@ -716,7 +746,8 @@ bool CaptureCardSource::connectDirectShowAudio(const SourceOpenDesc& desc){if(!bound){log::warn("capture-audio",std::format("binding=separate failed mode={} audioIndex={} audioPathTag={}",audio,audio,pathTag(selection.audioPath)));return false;}hr=p.graph->AddFilter(audioFilter.Get(),L"Capture audio");if(FAILED(hr)){log::warn("capture-audio",std::format("binding=separate AddFilter hr=0x{:08X}",uint32_t(hr)));return false;}- p.audioFilter=audioFilter;log::info("capture-audio",std::format("binding=separate embedded=0 audioIndex={} audioPathTag={} device=\"{}\"",audio,audio,pathTag(selection.audioPath),narrowForLog(filterName(audioFilter.Get()))));+ const std::wstring deviceName=p.pendingAudioName.empty()?filterName(audioFilter.Get()):p.pendingAudioName;+ p.audioFilter=audioFilter;log::info("capture-audio",std::format("binding=separate embedded=0 audioIndex={} device=\"{}\" pathTag={}",audio,narrowForLog(deviceName),pathTag(selection.audioPath)));}ComPtr<IPin> audioPin;hr=audioPinFor(p.builder.Get(),audioFilter.Get(),audioPin);if(FAILED(hr)){diff --git a/tests/unit/AverMediaAudioSwitchTests.cpp b/tests/unit/AverMediaAudioSwitchTests.cppindex f8b39548..bdf46bed 100644--- a/tests/unit/AverMediaAudioSwitchTests.cpp+++ b/tests/unit/AverMediaAudioSwitchTests.cpp@@ -45,6 +45,56 @@ int wmain() {check(!AverMediaAudioSwitch::isAverMediaDevicePath(L"{0.0.1.00000000}.{1234}"),"a WASAPI endpoint id is rejected");+ // Device-tree fallback. The card's DirectShow audio moniker may carry no+ // DevicePath at all (exactly what the 2026-09-17 field log showed), so the+ // switch has to be able to learn vid/pid from Windows itself.+ {+ const auto avermedia = AverMediaAudioSwitch::findUsbFunctions(L"vid_07ca");+ std::printf("note vid_07ca functions on this machine: %zu\n", avermedia.size());+ bool allMatch = true;+ for (const auto& function : avermedia) {+ std::wstring id = function.instanceId;+ for (wchar_t& c : id) c = wchar_t(towlower(c));+ if (id.find(L"vid_07ca") == std::wstring::npos) allMatch = false;+ }+ check(allMatch, "every returned function really belongs to the requested vendor");++ // Any USB device proves the enumeration itself works on this host; a+ // machine with no USB at all would make this vacuous, not wrong.+ const auto anyUsb = AverMediaAudioSwitch::findUsbFunctions(L"vid_");+ std::printf("note vid_ devices on this machine: %zu\n", anyUsb.size());+ check(!anyUsb.empty(), "device-tree enumeration finds USB functions");+ size_t withInterface = 0, withName = 0;+ bool pathsCarryToken = true;+ for (const auto& function : anyUsb) {+ if (!function.interfacePath.empty()) ++withInterface;+ if (!function.friendlyName.empty()) ++withName;+ std::wstring path = function.interfacePath;+ for (wchar_t& c : path) c = wchar_t(towlower(c));+ if (path.find(L"vid_") == std::wstring::npos) pathsCarryToken = false;+ }+ std::printf("note of those: interfacePath=%zu friendlyName=%zu\n", withInterface, withName);+ // The vendor component parses the literal lower-case tokens "vid_" and+ // "&pid_" out of whatever path we hand it, so that property is what the+ // fallback has to guarantee - not that a real interface path exists.+ check(pathsCarryToken, "every path handed to the vendor carries the vendor token");+ check(withInterface > 0, "at least one candidate resolves to a real interface path");+ check(withName > 0, "device friendly names are readable");+ }++ {+ std::vector<veyra::source::AverMediaUsbFunction> none;+ check(AverMediaAudioSwitch::pickAudioFunction(none) == nullptr, "no candidates -> no audio function");+ std::vector<veyra::source::AverMediaUsbFunction> single{{L"USB\\\\VID_07CA&PID_2553\\\\x", L"USB3 Video", L"\\\\?\\\\usb#vid_07ca&pid_2553#x#{g}"}};+ check(AverMediaAudioSwitch::pickAudioFunction(single) == &single.front(), "a single candidate is used");+ std::vector<veyra::source::AverMediaUsbFunction> composite{+ {L"USB\\\\VID_07CA&PID_2553&MI_00\\\\x", L"USB3 Video", L"\\\\?\\\\usb#vid_07ca&pid_2553&mi_00#x#{g}"},+ {L"USB\\\\VID_07CA&PID_2553&MI_02\\\\x", L"USB3 Digital Audio", L"\\\\?\\\\usb#vid_07ca&pid_2553&mi_02#x#{g}"}};+ const auto* picked = AverMediaAudioSwitch::pickAudioFunction(composite);+ check(picked != nullptr && picked->instanceId.find(L"MI_02") != std::wstring::npos,+ "the composite audio function is preferred over the camera functions");+ }+// Component discovery must either find a usable folder or report nothing at// all; a half-matched folder would hand garbage to LoadLibrary later.const std::wstring root = AverMediaAudioSwitch::locateComponentRoot();