VNOX-Client/docs/maintenance/microphone-monitor.md
loki5512344 f04691c3cd
chore(client): checkpoint deployed features and unfinished server management
User requested a checkpoint and stopped all agents. Deployed artifacts remain the last verified releases; unfinished settings/categories/forums are preserved as WIP. See TODO/roadmap for verification and remaining release/updater work.
2026-11-01 15:31:21 +01:00

41 lines
2.4 KiB
Markdown

# Local microphone monitor
The test opens the selected input and output for at most 30 seconds. It does not
send audio to a room. The live voice pipeline releases its devices before the
monitor starts; stop, settings close and device changes revoke the monitor.
## Correction — 2026-11-01
The former callbacks allocated vectors, independently restarted linear resampling
for every chunk, and used `try_lock` to share samples. Lock contention could drop
input or silence an output callback. Its queue permitted 250 ms of backlog.
The replacement uses preallocated atomic sample slots with one producer and one
consumer. Only the consumer advances the read position. A full producer drops
new samples and marks an overflow; playback discards stale queued audio before
prefilling fresh audio. Streaming resamplers retain phase across callbacks and a
bounded ±0.2% correction accommodates independent device clocks. Playback starts
with 20 ms, trims above 40 ms, and the ring holds at most 60 ms. Short gain ramps
smooth restart/underrun edges. The level meter holds and decays instead of resetting
visibly to zero on every UI poll. RNNoise reuses its 480-sample scratch buffers.
The monitor requests approximately 5 ms callbacks only within the device's
reported supported buffer range. If the request cannot build the streams, both
are rebuilt with device defaults. This is a request, not a measurement or a
promise of 5 ms end-to-end latency. Driver/server/hardware buffering and RNNoise
framing add delay. No desktop audio configuration is changed.
Synthetic checks exercise irregular 44.1/48/96 kHz callbacks, ±1000 ppm clocks,
concurrent ordered queue operations, overflow and stale-audio removal, underrun,
cancellation, and level hold/decay. They do not measure the user's headset or
establish human-perceived voice quality.
## Primary references
- [CPAL 0.18.2 BufferSize](https://docs.rs/cpal/0.18.2/cpal/enum.BufferSize.html)
- [PulseAudio stream buffering](https://freedesktop.org/software/pulseaudio/doxygen/streams.html#buffering)
- [PulseAudio client latency control](https://wiki.freedesktop.org/www/Software/PulseAudio/Documentation/Developer/Clients/LatencyControl/)
- [RNNoise frame API](https://github.com/xiph/rnnoise/blob/main/include/rnnoise.h)
The installed CPAL 0.18.2 Pulse backend was also inspected: fixed buffer requests
set `ADJUST_LATENCY`; default buffers leave the backend's defaults in place.