mirror of
https://github.com/storytold/soundcraft.git
synced 2026-11-28 14:08:07 -08:00
* Playback: strips render on the audio thread itself The realtime callback handed strips to rayon's global pool whenever a session had four or more, then waited for them. The pool's workers run at normal priority, so under CPU load the callback waited for starved workers (priority inversion) and blocked, which the callback must never do. On the audio thread strips now render one after the other on the thread itself; offline renders (bounces) keep the parallelism. `as_audio_thread`, which marked pool workers while they rendered for the audio thread, is no longer needed. A headless stress test (opt-in: `cargo test -p soundcraft-playback -- --ignored`) plays a 16-track session with an EQ and a compressor per track, one callback per 512-frame period, while all cores but one spin. Before: 23 and 30 of 1500 callbacks missed their deadline; after: none in two runs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Playback: count underruns and late callbacks; audio.health control method cpal reports underruns as `ErrorKind::Xrun`; they were only logged. The player now counts them, callbacks that overran their buffer period, and the worst callback load (relaxed atomics and one `Instant::now()` per callback, nothing on wasm32). `Player::health()` reads them; `Player::take_health()` reads and counts afresh without losing an event in between. The control channel reports them as `audio.health` (with the device's rate and buffer), and `soundcraft-cli app` knows it as a method. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * style: rustfmt the audio.health port cargo fmt --check failed on import grouping and a one-line if in the playback tests. * fix: cpal 0.18 sample_rate is a u32, and drop an unused import The output callback health timer used the old SampleRate newtype field, and note_stream_error removed the only use of Ordering in stream.rs. --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: FredApps <153173854+FredApps@users.noreply.github.com>