tools / audio

Audio probe β€” does the TV's capture PCM carry the final mix?

Status: run 2026-11-06 β€” the answer is no. The capture lane is dead on this model; see the result below. Written 2026-11-05, measured on the 50A51HUV (MTK9602, 09.01O.P0813) the next morning.

Why

The snapcast question (see TODO.md) and the librespot task (issue #19) both depend on one unknown: can a userspace process on this TV get audio in and out of the ALSA stack, and does it get what the room hears?

What is known:

What the probe answers

probe_alsa_capture.c opens a capture PCM, sets S16_LE / 48 kHz / stereo via snd_pcm_set_params, reads N seconds, and prints peak and RMS. Three outcomes:

Result Meaning
real audio the tap carries a signal β€” snapcast/librespot are viable
digital silence nothing playing, or this PCM is not the output mix
constant value the device opened but carries no signal

The question that actually matters is subtler than "does it work": if the tap sits before the TV's DSP and volume stage, a streamed copy will not match the speakers and the multiroom idea is much less useful. Compare the capture's loudness against the room while changing the TV volume β€” if the file does not change, the tap is upstream of the volume control.

Use

tools/audio/build.sh                 # zig cc, links the TV's own libasound
tools/audio/capture-probe.sh         # push, capture 3s, pull, clean up
python3 tools/audio/analyse.py /tmp/alvidaa-audio-build/cap.raw

build.sh pulls /vendor/lib/libasound.so.2.0.0 from the TV read-only and links against it with -target arm-linux-gnueabihf.2.31 to match the device's glibc. The binary needs /lib/ld-linux-armhf.so.3 and libasound.so.2, both present.

Safety

Result (2026-11-06): the capture lane is dead on this model

Measured on the 50A51HUV (MTK9602, 09.01O.P0813), first with the binary as built (b7d9172), then with the explicit-start / recover-instead-of-bail variant (1a5cc77):

Conclusion: on this model the TV's audio never enters a userspace ALSA stream. The mad_pcm nodes are the MStar decoder's internal interface, not the output mix, and nothing on the runtime side ever opens them. EIO is the correct answer, not a bug β€” there is no stream to read from.

Consequence: snapcast and librespot are not viable on this model through ALSA. Not a build problem, an architecture one β€” linking against the TV's own libasound cannot change what the kernel exposes.

The probe and build.sh stay in the tree: they are the evidence for this negative result, and the same experiment may answer differently on another SoC (the HiSilicon models ship different audio stacks).

Untested path: audio in the TV browser

One door stays open and is labelled as such. The TV browser (odin) is declared with --alsa-output-device=default;hw:0,0;..., so audio played in a web page might open a PCM where a native app does not β€” the browser's own audio stack sits between the page and the kernel and can take a path the media apps skip.

If anyone wants to close this off: play audio in the TV browser (any page with an <audio> element) and sample /proc/asound/card0/pcm*/sub0/status while it plays. If a sub0 flips to OPEN/RUNNING, the browser lane exists and the question reopens; closed everywhere closes the audio file for good. Do not assume this one β€” the native-path probe above was also written assuming it would work.