Epic: #113 · Milestone: MC5 — Audio
Why
drivers/sound.home is a 64-line mixer shim; audio/alsa.home and mixer.home are stubs. Playback needs a single clock owner: audio hardware position defines the master clock, video frames are scheduled against it. UI feedback sounds must mix over playing media without glitches.
Tasks
- Format negotiation: sink native rate (48 kHz), integer/float32 internal mix, channel layout mapping (mono/stereo/5.1 → sink), soft clipping/limiter (stdlib
audioDSP or a small Home port). - Resampler (polyphase, from stdlib
audioresampler.zigvia bindings, or Home) for 44.1 → 48 kHz music. - Lock-free ring buffers between decoder thread and the sink IRQ; underrun policy (silence + counter), latency ≤ 40 ms.
- Master clock API:
now()derived from sink DMA position with drift correction; exposed to the player (#85). - Volume curves (dB), mute, per-stream gain, UI-sound ducking; CEC/remote volume keys route here.
- Later: IEC61937 bitstream passthrough for AC3/DTS/E-AC3 (HDMI sink capability from EDID SAD blocks).
Acceptance
Mixing a UI click over 5.1 playback shows no underrun counter increase over 10 minutes; the A/V clock drift stays < 1 ms over an hour against the video timestamps.