Skip to content

mpris: report the correct position in Seeked - #1522

Merged
flyingmutant merged 1 commit into
cmus:masterfrom
pgaskin:mpris-seek-pos
Oct 23, 2026
Merged

flyingmutant merged 1 commit into
cmus:masterfrom
pgaskin:mpris-seek-pos

Conversation

@pgaskin

@pgaskin pgaskin commented Sep 24, 2026

Copy link
Copy Markdown
Member

And don't block the consumer while emitting it.

Instead of reading player_info.pos (which is always outdated since it is updated by player_info_snapshot), set a flag in player_info_priv and emit the signal after the next snapshot, like the other MPRIS signals.

Note that Seeked is no longer emitted for failed seeks.

closes #1408 (based on it, plus some fixes)

@pgaskin pgaskin mentioned this pull request Sep 24, 2026
@pgaskin
pgaskin force-pushed the mpris-seek-pos branch 3 times, most recently from af407ce to cf39369 Compare September 24, 2026 05:54

@pgaskin pgaskin left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I've tested this locally.

@flyingmutant

Copy link
Copy Markdown
Member

Maybe we'd need something like this to clear pending seek info when changing tracks?

--- a/player.c
+++ b/player.c
@@ -413,7 +413,7 @@
 
 /* updating player status {{{ */
 
-static inline void _file_changed(struct track_info *ti)
+static inline void _file_changed(struct track_info *ti, int reset_seek)
 {
 	player_info_priv_lock();
 	if (player_info_priv.ti)
@@ -423,6 +423,8 @@
 	update_rg_scale();
 	player_metadata[0] = 0;
 	player_info_priv.file_changed = 1;
+	if (reset_seek)
+		player_info_priv.position_seeked = 0;
 	player_info_priv_unlock();
 }
 
@@ -433,7 +435,7 @@
 	} else {
 		d_print("unloaded\n");
 	}
-	_file_changed(ti);
+	_file_changed(ti, 1);
 }
 
 static inline void metadata_changed(void)
@@ -1228,7 +1230,8 @@
 
 void player_file_changed(struct track_info *ti)
 {
-	_file_changed(ti);
+	_file_changed(ti, 0);
 }
 
 void player_seek(double offset, int relative, int start_playing)

And don't block the consumer while emitting it.

Instead of reading player_info.pos (which is always outdated since it
is updated by player_info_snapshot), set a flag in player_info_priv and
emit the signal after the next snapshot, like the other MPRIS signals.

Note that Seeked is no longer emitted for failed seeks. A pending seek
is also discarded if the track changes before the next snapshot, so
Seeked is not emitted with the previous track's position.

Co-Authored-By: Patrick Gaskin <[email protected]>
Co-Authored-By: Gregory Petrosyan <[email protected]>
@pgaskin
pgaskin removed the request for review from gavtroy October 10, 2026 08:15
@pgaskin pgaskin assigned flyingmutant and unassigned gavtroy Oct 10, 2026
@pgaskin

pgaskin commented Oct 10, 2026

Copy link
Copy Markdown
Member Author

Done and tested, @flyingmutant.

@flyingmutant
flyingmutant merged commit e82cc1f into cmus:master Oct 23, 2026
6 checks passed
@BrewTestBot BrewTestBot mentioned this pull request Oct 28, 2026
1 task done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants