mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-02 13:22:02 +00:00
Model playback latency from the device period, arrival jitter, source packet phase, and resampler delay. Treat audio:latencyOffset as an explicit addition to this minimum and align the first device pull to the next packet deadline. This starts playback near its steady-state target without unnecessary prefill or startup underruns. Use a 512-frame default period as a practical low-latency baseline. Replace the startup clock hold with a one-sided proportional acquisition controller, then hand off to source/device rate feed-forward and a slow phase loop. Calibrate the logical device timeline at handoff, discard correction that opposes the current error, and slew-limit rate changes. This prevents startup drain, integral wind-up, overshoot, and long convergence while preserving clock-drift compensation. Allow audio backends to expose a real-time resampler and use PipeWire's adaptive resampler when version 1.4 or newer supports it. Retain libsamplerate as the fallback and add audio:resampler to select the implementation. Wait for PipeWire stream setup to complete and propagate rate-control failures cleanly. Track PipeWire input-consumption and output-equivalent clocks separately. The input clock measures ring latency while the output clock drives feed-forward using the ratio that governed each request. This removes delayed self-feedback that made adaptive resampling oscillate between the correction limits. Reduce audio:debug output to useful latency, clock, jitter, and xrun values, and scale the playback graph from the startup estimate. Update the option names and documentation for the new latency model.