mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 06:25:41 +00:00
8f976dc371
audio_play and audio_chain_preload were both reading the same engine state (target_lufs, norm_mode, pre_analysis_db) and resolving the loudness cache, then feeding it into compute_gain — but with subtly different intermediate steps. audio_play split the resolve+post-resolve into two operations so it could log the cache value; chain_preload used the bundled `loudness_gain_db_or_startup` wrapper. Lift the shared logic into `resolve_track_gain_inputs(state, app, url, logical_id, js_loudness_gain_db) -> TrackGainInputs` in helpers.rs. The struct returns target_lufs, norm_mode, the cache-loudness value (for logging), and the post-resolve effective loudness for compute_gain. Both call sites now use the same helper; behaviour-preserving. Drops the now-unused `loudness_gain_db_or_startup` (audio_chain_preload was its only caller). audio/commands.rs: 676 → 642 LOC.