* 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>
When a strip's channel count changes, the first-two-channel peaks now take the new values
along with the per-channel ones. A take that finds no new block still drops the meters of
deleted tracks from the UI's copy.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The audio thread overwrote the shared meter snapshot every block (~94 blocks/s at 512
frames, 48 kHz) while the UI read it 20-60 times a second, so it only ever saw the latest
block and short transients were under-read. Blocks are now folded together (max of each
channel's peak and of the gain reduction; plugin failures keep the latest count) until the UI
takes them with Player::take_meters, which also starts a new period. Blocks rendered while the
UI holds the lock wait in an audio-side accumulator instead of being lost; the audio thread
still only try_locks.
Stopping, starting and locating now zero the meters in place instead of clearing the maps,
so playing again no longer re-allocates every track's entry on the audio thread. The UI
thread works out which tracks a session update deleted and tells the audio thread, which
drops just their entries.
The Mix window and the Renderer now read the snapshot the app takes once per poll instead of
reading the player themselves, so a period's peaks are not split between readers.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>