8000 feat(audio): hear the host computer's sound on the sending device by adeelahmad · Pull Request #28 · adeelahmad/gadgetcast · GitHub
[go: up one dir, main page]

Skip to content

feat(audio): hear the host computer's sound on the sending device - #28

Merged
adeelahmad merged 1 commit into
masterfrom
claude/project-thread-65265y
Oct 17, 2026
Merged

adeelahmad merged 1 commit into
masterfrom
claude/project-thread-65265y

Conversation

@adeelahmad
Copy link
Copy Markdown
Owner

Before: the USB speaker enumerated on the host, but anything the host played into it went nowhere. Someone using their phone as the call's mic and camera couldn't hear the call through it.

After: /send and the Studio send dialog have a "Play the computer's sound here" switch (off by default; the hint suggests headphones to avoid echo). When it's on, the on-air device plays what the host sends to the GadgetCast speaker.

How: a new GstSource supervises alsasrc (UAC2 capture) → opusenc → rtpopuspay → udpsink, and the bridge forwards those packets with WriteSpeakerRTP. With Options.Speaker, an offer whose audio is sendrecv gets an Opus track in the answer. Packets go only to the on-air client's track. Sendonly offers (older clients, or the switch off) are answered exactly as before. In the browser, SenderDeps.play turns the audio transceiver into sendrecv. Playback starts inside the Start tap, because phones block audio that doesn't start from a gesture. New flag: -speaker-device (default plughw:UAC2Gadget).

Test level:

  • Unit: on-air-only delivery across three Pion clients (sendrecv, sendrecv, sendonly), plus GstSource delivery and the pipeline string. Two vitest cases cover the direction and play/stop behaviour. go test -race passes; media coverage is 90.9%.
  • End to end without hardware: Playwright Chromium on /send with a stub gst-launch sending Opus RTP. With the switch on, the phone received 112 host-audio packets in 2s; with it off, it received 0. Mic and camera still reach the pipeline, and axe reports 0 violations on both send UIs.
  • Not tested on a Pi or a real USB host. The capture pipeline runs whenever gadgetcast runs. Its CPU cost on a Pi Zero is unmeasured.

Gate (local): gofmt, vet, build, go test -race ./..., armv6 and arm64 cross-builds, tsc, vitest (66), vite build.


Generated by Claude Code

The Pi captures the UAC2 gadget's speaker (what the host plays) as Opus
RTP and sends it to the on-air client when its offer's audio is
sendrecv. /send and the Studio send dialog get an off-by-default
"Play the computer's sound here" switch; older sendonly clients are
unchanged.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01K4B4YKMC6fT9oWCCwWgt9S
@adeelahmad
adeelahmad merged commit dc8061d into master Oct 17, 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.

2 participants

0