mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-21 23:05:46 +00:00
56d44046e3
`audio_chain_preload` runs ~30 s before the current track ends to queue the next source for sample-accurate gapless playback. It was also calling `Sink::set_volume(effective_volume)` with the *next* track's volume*ReplayGain — but `Sink::set_volume` affects the whole Sink, including the still-playing current source. Result: loudness of the currently-playing track audibly shifted exactly 30 s before its end, toward the next track's level. Move `set_volume` to the gapless transition block in `spawn_progress_task`, where `cur.replay_gain_linear` / `cur.base_volume` are already swapped. The boundary itself is still sample-accurate; only the volume update is deferred until the chained source is actually live. Side effects audited: - hi-res rate-mismatch fallback returns before the sink block — unaffected - manual skip during chain pending: audio_play creates a fresh Sink — unaffected - audio_set_volume / audio_update_replay_gain before transition operate on the current track's gain — still correct - after transition, cur.replay_gain_linear holds the chained track's gain before the new set_volume runs, so user volume changes remain correct - crossfade is mutually exclusive with gapless — separate code path Closes #275 Co-authored-by: Psychotoxical <dev@psysonic.app>