spotifyd icon indicating copy to clipboard operation
spotifyd copied to clipboard

MPRIS Seek and SetPosition implementations are incompatible with what playerctl expects

Open wasamasa opened this issue 3 years ago • 3 comments

Description

Basic playback control with playerctl is possible, but triggers an error or segfault when attempting to seek to an absolute/relative position. When inspecting the D-Bus interfaces with d-feet, it becomes obvious that spotifyd offers a different interface from all other software implementing the MPRIS specification.

20220907_132647

The Seek method expects a signed int64 to be able to seek backwards and forwards. Additionally, it is currently interpreted in milliseconds, but should be interpreted in microseconds.

The SetPosition method expects a string trackid (the rationale being "to avoid race conditions where a client tries to seek to a position when the track has already changed") and a signed int64 in microseconds. Given that the implementation looks very similar to the Seek one, it's likely it's interpreted in milliseconds instead.

To Reproduce

  • playerctl -p spotifyd position 10 to set absolute position to 10s
  • playerctl -p spotifyd position 10+ to seek forward by 10s
  • playerctl -p spotifyd position 10- to seek backward by 10s

To use d-feet:

  • d-feet
  • Click on "Session Bus"
  • Narrow down search results by entering "mpris"
  • Select the spotifyd one
  • Click on the /org/mpris/MediaPlayer2 path
  • Click on the org.mpris.MediaPlayer2.Player interface
  • Click on the methods

Expected behavior

  • spotifyd playback continues at 10s or 10s later or 10s earlier

Actual behavior

The first playerctl call segfaults:

(playerctl:251381): GLib-CRITICAL **: 13:52:57.116: g_variant_new_object_path: assertion 'g_variant_is_object_path (object_path)' failed

The second and third fail with a D-Bus error:

Could not execute command: GDBus.Error:org.freedesktop.DBus.Error.Failed: D-Bus argument type mismatch at position 0: expected u32, found i64

Logs

Click to show logs

No logs, duh

Compilation flags

  • [ ] dbus_mpris
  • [ ] dbus_keyring
  • [x] alsa_backend
  • [ ] portaudio_backend
  • [ ] pulseaudio_backend
  • [ ] rodio_backend

Versions (please complete the following information):

  • OS: Arch Linux
  • Spotifyd: 0.3.3 (7146f64a819590a16de9991de74f8bc2fea9c2ac) https://aur.archlinux.org/packages/spotifyd-full-git
  • cargo: 1.63.0

wasamasa avatar Sep 07 '22 11:09 wasamasa

Thanks for the report! Apart from the two that you discovered, there are also some other methods that don't strictly conform to the spec. (There is only VolumeUp and VolumeDown, but no Volume.)

But the one that you mention should be quite easy to fix, I'll create a PR.

eladyn avatar Sep 08 '22 10:09 eladyn

Thank you, I've tested now with playerctl as well and it stopped raising errors and segfaulting.

wasamasa avatar Sep 11 '22 07:09 wasamasa

Should this be in https://github.com/Spotifyd/spotifyd/milestone/11? 0.3.4 will come with MPRIS support, so fixing it up fully might be a worthy target.

flying-sheep avatar Sep 11 '22 13:09 flying-sheep