Skip to content

Fix flow mode not switching sample rate between tracks on wrapped players#4685

Draft
MarvinSchenkel wants to merge 3 commits into
devfrom
fix/flow-mode-sample-rate-restart
Draft

Fix flow mode not switching sample rate between tracks on wrapped players#4685
MarvinSchenkel wants to merge 3 commits into
devfrom
fix/flow-mode-sample-rate-restart

Conversation

@MarvinSchenkel

@MarvinSchenkel MarvinSchenkel commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What does this implement/fix?

Flow mode streams were stuck at the first track's sample rate on wrapped players (e.g. players behind a Universal Group): the mid-flow restart check re-resolved the player from the queue id, which returns the wrapper player. That wrapper has no audio/protocol config entries, so the check fell back to 44.1kHz/16bit defaults and the sample-rate switch never triggered.

  • Pass the protocol player (the player actually requesting the flow stream, and the one the flow PCM format was anchored on) into get_queue_flow_stream()
  • New _flow_restart_context() helper resolves the flow mode config and supported sample rates from that player, falling back to the queue's player when not given
  • Add unit tests for the helper (protocol player preferred, queue-player fallback, no player at all)

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.

In flow mode the PCM format is anchored on the (protocol) player that
requests the stream, but the mid-flow restart check re-resolved the
player from the queue id. For wrapped players (e.g. Universal Player
around a DLNA renderer) that wrapper has no audio config entries and
falls back to 44.1kHz/16bit, so every next track snapped to the flow
rate and bit-perfect/smart modes never restarted the flow. The stream
then stayed pinned at the first track's sample rate until a manual
seek forced a fresh flow.

Pass the requesting player into get_queue_flow_stream so restart
decisions use the same supported sample rates and flow mode config
that anchored the flow format.
@MarvinSchenkel
MarvinSchenkel force-pushed the fix/flow-mode-sample-rate-restart branch from 8bbe74c to e48d3ae Compare July 9, 2026 10:57
@codspeed-hq

codspeed-hq Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 18 untouched benchmarks


Comparing fix/flow-mode-sample-rate-restart (e48d3ae) with dev (6c538ca)

Open in CodSpeed

@MarvinSchenkel

Copy link
Copy Markdown
Contributor Author

Waiting for user confirmation in the related issue

@marcelveldt

Copy link
Copy Markdown
Member

I'm pretty sure this one was already fixed last week or the week before where the active protocol would be resolved to get the active setting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants