Skip to content

feat: UAC USB 麦克风透传 - #284

Closed
arounyf wants to merge 1 commit into
mofeng-git:mainfrom
arounyf:fix/hid-reload-on-gadget-rebuild
Closed

feat: UAC USB 麦克风透传#284
arounyf wants to merge 1 commit into
mofeng-git:mainfrom
arounyf:fix/hid-reload-on-gadget-rebuild

Conversation

@arounyf

@arounyf arounyf commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

浏览器麦克风 → Opus(WebCodecs 64kbps) → WebSocket → one-kvm → aplay → UAC1 Gadget → Windows USB 麦克风

数据流

浏览器 getUserMedia() → AudioEncoder(Opus 64kbps) → WebSocket → one-kvm → audiopus 解码 → PCM → aplay 子进程 → UAC1 Gadget (ConfigFS) → DWC3 USB → Windows USB 麦克风

带宽优化

Raw PCM (48kHz stereo S16LE) ~1.5 Mbps → Opus 64kbps ~16 kbps (100× 缩减)

新增文件

  • src/otg/uac.rs — UAC1 ConfigFS gadget
  • src/audio/uac_streamer.rs — aplay 子进程 PCM 播放
  • src/audio/uac_websocket.rs — WebSocket Opus/PCM 接收
  • src/web/uac_ws.rs — /api/ws/uac-audio 端点
  • src/web/handlers/config/uac.rs — UAC 配置 API
  • web/src/composables/useMicrophone.ts — 浏览器麦克风+Opus 编码

关键修复

  • DWC3 复合设备等时端点: c_chmask=0 + req_number=4 + UAC 优先创建
  • aplay 欠载恢复: 空闲后强杀旧进程, buffer-size=32768

UI

  • 设置页 UAC 开关
  • 操作栏麦克风按钮(UAC 未开自动隐藏)

- Bump buffer-size 32768 (680ms) to tolerate WebSocket jitter
- Force-spawn fresh aplay when resuming after idle (was_idle flag)
- Extend idle timeout 2s→5s for speech pauses
- Suppress aplay stderr (underrun noise)
@arounyf arounyf closed this Jul 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant