fix: 修正 UAC 链接顺序及原生 ALSA 启动恢复 - #309
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
针对 #291 报告的 DWC3 UAC 麦克风透传无法启动、界面停留在等待目标机的问题,保留 One-KVM 内部的原生 ALSA 实现,修正 USB 功能链接顺序、PCM 启动和恢复逻辑。复用现有
alsa/libasound,不引入aplay、子进程管道、后台线程或额外音频队列。验证:在现有开发工作区运行
cargo test --offline --target x86_64-unknown-linux-gnu --lib audio::uac::playback::tests(10 个通过)及cargo test --offline --target x86_64-unknown-linux-gnu --lib otg::manager::tests(4 个通过),覆盖短写、设备无空间、消费进度、原生 PCM 启动/恢复、停止关闭、空闲恢复及链接顺序/失败路径。原生 PCM 测试使用 ALSA null 设备。两处修改文件在 dev 与本 PR 的 main 基线完全相同;格式检查及git diff --check通过。2026-09-10 实机验证:RK3588 BlueBerry(5.10.110 #68、libasound 1.2.4)+ Windows USB 音频接收端。独立测试实例创建 UAC1 + 4 HID + MSD,使用 DWC3
ep2in等时端点。原生非阻塞 PCM 成功进入 RUNNING,实际协商为 48 kHz 双声道 S16_LE、period 1024、buffer 16384;未出现 EPIPE 启动失败。完整链路
WebSocket PCM → One-KVM 原生 ALSA → USB → Windows 录音通过:首次和恢复后各录得 6 秒,频率分析确认左声道 440 Hz、右声道 880 Hz。目标端停止/恢复录音时状态按预期经历 waiting → active → stalled → active。独占会话返回 409、输入空闲超过 5 秒后重开 PCM、会话关闭释放 PCM、新会话重新打开也通过。录音首个测试信号在开始后约 370–375 ms 出现,包含启动缓冲和主机采集,不能视为精确的端到端延迟。Gadget 删除重建的实机回归仍未完成:预先进行的临时 Gadget 能力探测触发了旧厂商内核的
android_setup → __raw_spin_lock_irqsavepanic(当时 PR 程序尚未运行)。崩溃与 2023 年 Rockchip configfs.c 中首个 Gadget 删除后全局android_device指针失效的缺陷吻合;确切厂商源码版本未取得。重启后首个 Gadget 的上述播放测试通过;没有重复执行会触发该问题的删除重建测试,也没有修改内核。测试结束已停止独立实例并重启恢复环境,原服务程序和配置保持不变。较大缓冲作为兼容性起点,会增加音频延迟,后续可根据实机结果调优。空闲处理发生在恢复输入时,不是后台定时关闭。