audio: Day 2 — Codex follow-up hardening (channel disconnect, spawn_blocking, fallback silence guard, requeue counting, runtime error propagation)
Closes the 6 Codex review findings on the Day 1 mic-capture work (commits96980c7+41db162). Detail in output/reports/kon-codex-mic-capture-followup-2026-04-17.md (CORBEL workspace). src-tauri/src/commands/audio.rs: - D1: Sending an explicit stop signal before dropping stop_tx, so the accumulator task wakes up immediately rather than waiting for the Disconnected detection added below. - D2: Wrapping MicrophoneCapture::start() in tokio::task::spawn_blocking. start() can spend up to 350ms × N_devices × 2 passes; running it on the async runtime froze other Tauri commands. - M3: Match on rx.try_recv() error variants. Empty -> sleep + continue. Disconnected -> exit accumulator task immediately. Previous behaviour was an infinite loop after the capture stream died. crates/audio/src/capture.rs: - D3: Added DEAD_SILENCE_FLOOR (1e-7) gate that applies even in the fallback pass. PulseAudio/PipeWire can stream zero-valued bytes from a borked device; that is worse than failing fast. - M1: Validation requeue (`for chunk in collected { try_send }`) now counts drops in the same dropped_chunks counter. - M2: New CaptureRuntimeError type. The cpal stream error callback now forwards errors via a separate sync_channel (capacity 16) that the live session can drain via take_error_rx() and surface as toasts. Re-exported from kon_audio crate root. cargo check -p kon-audio passes clean. NOT YET DONE (M4): JACK-specific monitor name patterns. Defers until testing on a JACK host. Current is_monitor_name() may miss JACK conventions. Wiring the new error_rx into the live session and surfacing as toasts lands with the Day 3 error-toast system commit.
This commit is contained in:
@@ -6,7 +6,7 @@ pub mod streaming_resample;
|
||||
pub mod vad;
|
||||
pub mod wav;
|
||||
|
||||
pub use capture::{AudioChunk, DeviceInfo, MicrophoneCapture};
|
||||
pub use capture::{AudioChunk, CaptureRuntimeError, DeviceInfo, MicrophoneCapture};
|
||||
pub use concurrency::decode_and_resample;
|
||||
pub use decode::decode_audio_file;
|
||||
pub use resample::resample_to_16khz;
|
||||
|
||||
Reference in New Issue
Block a user