Skip to content

Add USB audio gadget permission setting#1479

Merged
adamshiervani merged 6 commits into
devfrom
fix/audio-gadget-disabled
May 29, 2026
Merged

Add USB audio gadget permission setting#1479
adamshiervani merged 6 commits into
devfrom
fix/audio-gadget-disabled

Conversation

@adamshiervani
Copy link
Copy Markdown
Contributor

@adamshiervani adamshiervani commented May 26, 2026

Adds USB Audio to the USB Devices setting as the explicit permission gate while keeping the live audio gadget enabled only when both USB Audio and Audio are enabled.

When USB Audio is disabled, Audio settings now disable the toggle and point users back to Hardware with a concise, inline hint.


Note

Medium Risk
Changes USB composite gadget composition and WebRTC audio attachment, which can trigger host re-enumeration; logic is covered by unit tests and coordinated RPC/config paths.

Overview
This PR adds USB Audio as an explicit permission in USB Devices, while the host only sees the audio gadget when both that toggle and Audio streaming are enabled.

Backend: usbgadget.Devices gains an audio flag; gadget config and JSON-RPC (setUsbDevices, setUsbDeviceState, setAudioConfig) keep AudioEnabled, USB audio permission, and the live gadget in sync—disabling USB audio clears streaming config, stops audio, and reapplies the composite device via effectiveUsbDevices() / effectiveAudioEnabled(). Config load reads the file as raw JSON so older configs without usb_devices.audio pick up the new default and force audio_enabled off when USB audio is off. WebRTC only attaches an audio track when both gates pass.

UI: Hardware settings expose the USB Audio checkbox and updated presets; the Audio page disables its toggle with an inline hint linking to Hardware when USB Audio is off. Locales and a small e2e keyboard readiness check are updated.

Reviewed by Cursor Bugbot for commit 966d43f. Bugbot is set up for automated code reviews on this repo. Configure here.

Comment thread ui/src/routes/devices.$id.settings.audio.tsx
@mcuelenaere
Copy link
Copy Markdown
Contributor

mcuelenaere commented May 26, 2026

FYI: this just bit me while I was rebasing my PRs: my CDC-NCM usb gadget was silently (partially) broken, because of too few available USB IN endpoints. The RX side was working fine, but the TX side didn't do anything (and I spent some time chasing phantom bugs).

I'll add a UI warning to #1470 about exceeding the IN-endpoint budget to prevent users from making the same mistake in the future

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f13be06. Configure here.

Comment thread jsonrpc.go
@adamshiervani adamshiervani marked this pull request as ready for review May 29, 2026 06:57
@adamshiervani adamshiervani merged commit 800c0cb into dev May 29, 2026
5 checks passed
@adamshiervani adamshiervani deleted the fix/audio-gadget-disabled branch May 29, 2026 06:57
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.

2 participants