Repository navigation
fix: export one coherent track to mpris while the now-playing text is held - #568
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #565
What changes
Since #563,
BridgeClientholds the now-playing text (title, artist, album, genre, year, number) of the track before until the new track's queue row or metadata arrives. During that hold, MPRIS exported the new track'smpris:trackid, URL and length next to the old track's text. This PR uses the issue's first option: MPRIS exports the track the now-playing text describes, and always exports it whole.BridgeClient::currentTrackTextPath()exposes the track the text describes (m_currentTrackTextPath).m_currentTrackTextPathnow sets the track-metadata change, even when the two tracks' tags read the same. Before, the path changed silently, and nothing told MPRIS that the hold had ended.BridgeClient::currentTrackCoverTrackPath()records, where the cover is chosen, which track the cover belongs to. Since fix: keep the previous cover until the next track's cover is known #523, the bridge keeps the previous track's cover until the new track's own is known, which can be after its text resolves (from a queue row with no cover, or a stop). A change of this track also counts as a metadata change, so the same image becoming the new track's own is published.MprisControllerexportsexportedTrackPath(): the text's track, or the playing track when the text describes none (the first track after start-up). The rules:PropertiesChanged.mpris:artUrlis exported only when the bridge's cover belongs to the exported track; until then it is left out, never the previous track's. The album artist already comes only from the track's own metadata.Playback commands
SetPositionaccepts the exported ID and the playing track's ID, and seeks the playing track, clamped to its duration. The MPRIS spec ignores a call whose ID is not the current track's as stale. A client can only learn the current track fromMetadata, so during the hold a correct client sends the exported ID (the track before's), and it means the playing track. Rejecting that call would break seeking from the applet, the lock screen or KDE Connect for the length of the hold. Accepting the playing track's own ID as well means that a client that knows it is never refused either. Any other ID is still stale.Seekedis now sent when exactly one of "a new play started" and "the export moved to another track" happens, unless playback is stopped:Seekedfollows thePropertiesChangedwith the real position.Seekedis sent, as before.Known trade-offs of option 1
The hold usually lasts only until the metadata reader's first result.
Seekedkeeps the position itself right.Tests
All in
ui/tests/tst_bridge_client.cpp, throughBridgeClient::processBinarySnapshotandMprisControllerwith a signal sink:mprisExportsTheTrackBeforeWholeWhileTheTextIsHeld: during the hold, the metadata stays the track before's (whole map, including length) across identity, heartbeat and new-length signals, and noMetadatachange is published. The switch is onePropertiesChangedwith the new track whole. Every publishedMetadatais checked for an ID paired with another track's URL, title, artist, album or length. The test also covers theSeekedbehaviour and Position.mprisSetPositionDuringTheHoldSeeksThePlayingTrack: SetPosition with the exported ID (past the old track's length, within the new one's) and with the playing ID both seek. An unrelated ID is ignored, and a relative Seek works.mprisHoldFollowsASecondTrackChangeAndEndsOnStop: a second change during the hold, an untagged track, and a stop during the hold. No published metadata names the skipped track or mixes two tracks, and the stop is not reported as a seek.mprisExportsNoArtOfTheTrackBeforeAfterTheRowEndsTheHold: the tracks have distinct art. The next track's queue row (without a cover) ends the hold before its metadata arrives. MPRIS exports the new track without art or album artist, then with its own once its metadata arrives.mprisExportsNoArtOfTheTrackBeforeAfterAStopEndsTheHold: a stop during the hold exports the stopped track under its file name, without the previous track's art or album artist.mpris:artUrlandxesam:albumArtist(either may be left out, but must never be another track's).mprisHoldEndsForATrackWhoseTextReadsTheSame: the bridge reports the text-path change, and MPRIS exports the new ID.exportedTrackPath()reverted to the playing path, the four hold tests fail../scripts/run-tests.sh --ui-onlypasses: 102/102 CTest tests, including the no-private-Qt-API checks, with no new compiler warnings. No Rust changes.