AUDIO
Source snapshot · 11 November 2026

Standalone audio devices

Control thread

output_devices() returns host-local IDs, names and output configuration ranges. output_device(Some(id)) selects that ID with no default fallback; None selects the current default. Refresh enumeration after device changes. IDs belong to the backend and are not promised to be portable across machines or reinstallation. CPAL errors are returned rather than replacing devices silently. A device whose ID, name or configurations cannot be read is left out of output_devices() and input_devices() instead of failing the whole list (decision 0296). On Linux ALSA a hardware PCM held open by another application (for example a DAW using hw: directly) reports DeviceBusy; it is omitted while the PipeWire/PulseAudio default and pipewire PCMs stay listed. Only a host-level enumeration failure is an error.

Pass an explicit CPAL StreamConfig to open_output, a maximum scratch frame count and an owned Processor<f32> + Send + 'static. There is no implicit sample format conversion, sample-rate fallback or resampling. The device must support f32 at the requested settings. Fixed buffer sizes are backend requests; callbacks may have another size. Prepare allocates scratch before building the stream. Call play, pause and drop from the control thread. Pause/resume retains history and logical sample position. Stream callbacks classify CPAL notifications as described below; recovery is caller-directed stream reopening, not a callback action.

Stream statistics and recovery faults

OutputStatistics and InputStatistics expose three independent counters for CPAL error-callback invocations, shared by ordinary, duplex, clocked, reclaimable, graph, file and recording paths:

Previously all error-callback invocations incremented backend_errors, so a single xrun could latch an application's audio fault and cause an unnecessary rebuild. Caller-scheduled output, duplex, clocked and reclaimable clocked recovery now leave streams running after xruns and route changes. They still recover on backend_errors or their existing panic counters; disappearance found by exact-ID enumeration and explicit reopen requests retain their existing behavior. Ordinary DSP faults and FIFO shortage/drop counters retain their separate policies.

Counts use wrapping relaxed atomics, are not coherent snapshots and only cover notifications delivered by CPAL. Zero xruns do not prove glitch-free audio. Classification performs no logging, allocation, device queries or stream lifecycle work. Applications can inspect the new counters without treating them as permanent audio faults. Exhaustive statistics construction/destructuring must include the new fields or use Default/.. as appropriate. See decision 0278.