Skip to content

Fix track duration shrinking when seeking near the end with smart crossfade#4176

Merged
marcelveldt merged 1 commit into
devfrom
fix-5494-crossfade-duration
Jun 12, 2026
Merged

Fix track duration shrinking when seeking near the end with smart crossfade#4176
marcelveldt merged 1 commit into
devfrom
fix-5494-crossfade-duration

Conversation

@MarvinSchenkel

@MarvinSchenkel MarvinSchenkel commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

What does this implement/fix?

With smart crossfade enabled, the last part of each track (up to 45s) is held back as the crossfade tail. The end-of-track duration recalculation excluded this tail, so the reported track duration shrank by up to the crossfade length. After seeking near the end of a track the error is large enough that the duration drops below the play position, breaking the seekbar and the duration/position reported to HA entities. The shrunken value was also reused on the next seek, compounding the error.

  • Flow mode: include the held-back crossfade tail when recalculating the track duration, and drop the now duplicate end-of-queue correction
  • Single item mode: credit the full fade-out tail (instead of the trimmed fadeout share of the mix) to the duration

Related issue (if applicable):

Types of changes

  • Bugfix (non-breaking change which fixes an issue) — bugfix
  • New feature (non-breaking change which adds functionality) — new-feature
  • Enhancement to an existing feature — enhancement
  • New music/player/metadata/plugin provider — new-provider
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) — breaking-change
  • Refactor (no behaviour change) — refactor
  • Documentation only — documentation
  • Maintenance / chore — maintenance
  • CI / workflow change — ci
  • Dependencies bump — dependencies

Checklist

  • The code change is tested and works locally.
  • pre-commit run --all-files passes.
  • pytest passes, and tests have been added/updated under tests/ where applicable.
  • For changes to shared models, the companion PR in music-assistant/models is linked.
  • For changes affecting the UI, the companion PR in music-assistant/frontend is linked.
  • I have read and complied with the project's AI Policy for any AI-assisted contributions.
  • I have raised a PR against the documentation repository targeting the main or beta branch as appropriate.

@MarvinSchenkel MarvinSchenkel force-pushed the fix-5494-crossfade-duration branch 3 times, most recently from 082ae47 to 1315dc2 Compare June 11, 2026 18:08
@MarvinSchenkel MarvinSchenkel force-pushed the fix-5494-crossfade-duration branch from 1315dc2 to 3560d8f Compare June 11, 2026 18:09
@MarvinSchenkel MarvinSchenkel marked this pull request as ready for review June 11, 2026 18:13
Copilot AI review requested due to automatic review settings June 11, 2026 18:13

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes incorrect track duration recalculation when smart crossfade is enabled, specifically preventing the reported duration from shrinking after seeking near the end of a track (which could break UI seekbars and HA entity state).

Changes:

  • Single-item (gapless) smartfade: account for the held-back fade-out tail when recomputing streamdetails.duration.
  • Flow-mode streaming: include the held-back crossfade tail in per-track duration recomputation, and remove the now-duplicate end-of-queue duration correction.

Comment thread music_assistant/controllers/streams/audio.py
Comment thread music_assistant/controllers/streams/audio.py
@marcelveldt marcelveldt merged commit 69be0c9 into dev Jun 12, 2026
13 checks passed
@marcelveldt marcelveldt deleted the fix-5494-crossfade-duration branch June 12, 2026 06:46
anatosun pushed a commit to anatosun/music-assistant-server that referenced this pull request Jun 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants