Call audio spike: learnings (2026-11-15)
Field notes from getting Milestone 3 call audio working end to end on the
author’s hardware. Read this before touching tetherd’s features/audio.rs,
pipewire.rs or the phone’s TetherInCallService. Decisions are in
ADR-0015 (with its 2026-11-15 amendment); the D-Bus behaviour is in
docs/reference/dbus-api.md (“Call audio”, “Echo cancellation”, “SetCallAudio”).
Setup this was learned on
| Part | Version |
|---|---|
| Desktop | Linux Mint (Ubuntu 24.04 base), kernel 6.17 OEM, Cinnamon/X11 |
| Audio | PipeWire 1.0.5, WirePlumber 0.4.17, pipewire-pulse |
| Bluetooth adapter | Realtek RTL8852BU (USB 0bda:4853), BlueZ from the distro |
| Phone | Galaxy A55, Android 16 / One UI 8.5 |
| Call codec | mSBC (wideband), PC = HFP hands-free, phone = audio gateway |
Starting symptoms
- Calls could be placed and answered from the laptop, but the in-call window always said “Audio on the phone” and the caller mostly could not hear the laptop user.
- The audio buttons (This PC / Phone / Speaker) did nothing.
Findings
1. PipeWire exposes a phone’s call audio as streams, and only while SCO is up
The daemon looked for HFP nodes with media.class Audio/Source and
Audio/Sink. That is what a headset card exposes. When the remote device is
a phone (we are the hands-free unit), PipeWire’s sco-source.c / sco-sink.c
create:
| Node | media.class | Direction |
|---|---|---|
bluez_input.<MAC>.N | Stream/Output/Audio | caller’s voice into the graph |
bluez_output.<MAC>.N | Stream/Input/Audio | our microphone to the phone |
Both carry media.role = Communication and api.bluez5.profile = headset-audio-gateway. Because they are streams, WirePlumber links them to
the default sink and source by itself; no pw-link is needed in the normal
case.
They are also dynamic: bluez5-device.c emits them when the SCO transport
goes to pending/active and removes them when it goes idle. Consequences:
- “The HFP nodes exist” is the reliable signal for “call audio is on the PC”. The daemon now polls the graph once a second during a call instead of waiting 3 s once and giving up.
- Selecting the card profile does not create them. The profile on this
machine is always
audio-gatewayalready. - The PC cannot pull the audio to itself. PipeWire only opens SCO when a node is started, and there is no node without SCO. Moving audio to the PC always needs the phone to open the link.
- The PC can push audio away: switching the phone card’s profile to
offdestroys the nodes, which closes SCO; Telecom then falls back to the earpiece. The daemon restores the profile about half a second later so the next call can use the PC again. This is the fallback for “Phone” when the phone refusesROUTE.
The old unit-test fixture had the wrong classes, which is why the tests were green while the feature never worked. The fixture now uses the classes and port names seen on the real graph.
How to see it: during a call, pw-dump | grep -c headset-audio-gateway and
pw-link -l | grep -A2 bluez_.
2. Android 16 binds a third-party InCallService only with MANAGE_ONGOING_CALLS
Without a bound InCallService the app cannot route call audio
(setCommunicationDevice and setSpeakerphoneOn only affect the app’s own
audio; BluetoothHeadset.connectAudio is privileged), so every ROUTE
answered route_unsupported.
What does not bind the service on One UI 8.5:
- holding
CALL_COMPANION_APP(granted, normal permission); adb shell telecom add-or-remove-call-companion-app org.tether.android 1(exit code 0, no effect; Telecom logsSkipping binding to … control: false, car-mode: false, ui: false).
What does:
adb shell appops set org.tether.android MANAGE_ONGOING_CALLS allow
plus <uses-permission android:name="android.permission.MANAGE_ONGOING_CALLS"/>
in the manifest (signature|appop; the app-op check needs the declaration).
The clue was adb shell appops get org.tether.android MANAGE_ONGOING_CALLS
showing a fresh rejectTime right after a call started. An app-op grant is
expected to survive reboots (not yet re-checked after a reboot). With it,
requestCallEndpointChange works for Bluetooth, earpiece and loudspeaker, and
the service also gives exact per-call state.
This belongs to the adb tier (ADR-0007); the M4 “auto-grants” step should apply it together with the other grants.
3. No echo cancellation means the caller loses our voice
Once audio flowed, the caller heard roughly 60–70 % of the speech cleanly, with gaps, and sometimes heard themselves. Cause: laptop speakers feed the caller’s voice back into the laptop microphone. PipeWire’s hands-free role does not announce echo cancellation, so the phone (and the network) treat the returning voice as echo and suppress our uplink while the far end makes sound.
Fix: PipeWire’s module-echo-cancel with the WebRTC canceller on the
microphone path for the duration of a call, only when the call uses the
default sink and source (a headset does not need it).
Two layouts were tried:
| Layout | Result |
|---|---|
Virtual sink + virtual source (pactl load-module module-echo-cancel), both call directions moved onto them | Echo gone, but one side dropped out intermittently; more dropped-buffer messages and an ALSA resync |
Monitor mode (monitor.mode = true): caller’s voice stays linked to the real sink, the canceller reads the sink’s monitor as reference, only the microphone side moves to tether_call_mic | Echo gone, both directions clear |
Monitor mode is not reachable through pipewire-pulse’s module-echo-cancel
arguments, and a module loaded with pw-cli load-module dies with pw-cli.
The daemon therefore writes a small config to
$XDG_RUNTIME_DIR/tether-echo-cancel.conf and runs pipewire -c <conf> as a
child (killed when the calls end or the daemon exits). The phone’s microphone
node is pointed at the cancelled source with
pw-metadata <node id> target.object tether_call_mic; WirePlumber 0.4 accepts
a node name there and moves the link.
Things to keep in mind:
- The first 2.5–4 s of a PC call run without cancellation: the daemon waits for WirePlumber’s own linking (which may itself wait 2 s for a remembered target) before it starts the canceller.
- After a mid-call switch away and back, the new SCO link brings new nodes, and PipeWire may reuse the old node ids. The “already targeted” list must be cleared when the nodes disappear.
- WirePlumber’s
restore-streamremembers the target under the generic keyInput/Audio:media.role:Communication. It only applies a remembered target when that node exists, so the entry is harmless outside calls. - While the canceller owns the routing, the daemon must not add links to the raw microphone “to repair” a moment without links.
4. Things that looked like causes and were not
- Quantum. WirePlumber logs
out of buffers on port 0 1during calls (the mic stream handing buffers to the SCO sink). Forcing a small quantum (clock.force-quantum 256) in an A/B test made it worse (16 messages in 20 s against 0–5 at the default 1024). The loss at the default is around 100 ms per 20 s, far too little to explain missing words. Not changed. Bluetooth: hci0: corrupted SCO packetin the kernel log on the Realtek adapter: appeared in bursts, not during the bad stretches of the A/B call. mSBC was kept; forcing CVSD was not needed.- Microphone level, phone microphone mute, WirePlumber’s remembered target pointing at absent earbuds: all checked and ruled out.
How the daemon behaves now
CallAudiofollows the graph, including switches made on the phone.- Once per call it sends
ROUTE bluetoothwhen the user wants PC audio and the phone did not pick the PC. - 2.5 s after the nodes appear it adds any missing link to the default devices and leaves a direction alone that the session manager linked elsewhere (a headset).
- It runs the echo canceller as described (config key
call_echo_cancel, default true). SetCallAudio phonefalls back to closing SCO from the PC when the phone refuses;speakerandpcreport a readable reason instead.
Diagnosis recipe for next time
- Daemon:
journalctl --user -u tetherd | grep -E 'CallAudio|call audio|echo'. - Graph during the call:
pw-dump(node classes, state),pw-link -l,pw-top -b -n 2. - Session manager and kernel:
journalctl --user -u wireplumber -u pipewire,dmesg | grep -i sco. - Phone:
adb logcat | grep -E 'Tether\.Calls|InCallController',adb shell dumpsys bluetooth_manager(sectionHeadsetService: state machine log shows when SCO opened and closed),adb shell dumpsys telecom | grep -i tether,adb shell appops get org.tether.android MANAGE_ONGOING_CALLS. - Read the PipeWire source for the installed version rather than guessing:
spa/plugins/bluez5/{sco-source,sco-sink,bluez5-device,backend-native}.c. - When the far end’s experience is the question, run a timed A/B during one call with desktop notifications naming each phase, and ask the other side which phase was clean.
Process lessons
- A capture armed before the call (graph snapshots every 2 s while the HFP nodes exist) answered more than any amount of reading. Arm it before every test call.
- Unit tests built on an assumed
pw-dumpshape gave false confidence. Take fixtures from a real capture. pw-dumpcan print a second JSON array when the graph changes while it runs; parse the first value only.pkill -fmatched the calling shell again during this work. Usepkill -x, or a pattern that cannot match the caller.
Open items
-
Occasional static-like noises during PC calls (reported by the user on the final test with the release build, 2026-11-15; accepted for 0.3.0). Not diagnosed. Candidates: the remaining
out of buffersdrops on the microphone path,corrupted SCO packetbursts from the Realtek adapter with mSBC, or WebRTC canceller artefacts (try its noise-suppression and gain-control arguments, or CVSD). Capturepw-top, the WirePlumber journal anddmesgduring a call where it happens. -
Re-check the app-op grant after a phone reboot.
-
Each switch back to the PC re-points the microphone node about a second after the nodes appear; until then the raw microphone is linked.
-
Cancellation starts a few seconds into the call; starting the canceller as soon as the nodes appear would close that gap.
-
In-band ringing opens SCO while the call still rings, so the PC ringtone and the phone’s ringtone can both play on the PC.
-
The small
out of buffersloss on the microphone path remains (PipeWire 1.0 SCO sink following the ALSA clock); revisit on PipeWire ≥ 1.2. -
Other adapters and phones are untested. If one-way audio shows up with everything linked, try CVSD (
bluez5.enable-msbc = falsein a WirePlumber drop-in); note that it also narrows headset microphones on that PC.