-
Notifications
You must be signed in to change notification settings - Fork 455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade librespot to 0.2.0 #977
Conversation
I'm desperate for an upgrade to MPRIS so I tested this PR. Here's what I found:
Oh and also enabling Would love to help getting any of this debugged if needed, because otherwise the MPRIS feature will remain unusable if you wish to control multiple players, not just spotifyd. |
Hi @busimus!
Thanks for testing out this PR; this is all super helpful feedback. I'm
away from my computer until Wednesday and will take a look sometime
after I'm back.
For what it's worth - I totally agree with you about the DBUS situation
in general. The implementation here calls out to the Spotify web api for
almost every DBUS message (PlayerStatus and Metadata being two of the
most notable). I've tried to keep that the same in this PR in order to
limit the scope of the PR, but I've also been working on a fix for that.
The fix hooks into librespot's player events and metadata retrieval
functionality. It's made a huge improvement in my tests (no need for a
network call on DBUS message!) but requires some changes to the upstream
librespot dependency to work as currently implemented. I'll share the
code for that with you when I'm back too; if you're interested in
testing.
|
Hey! I tested this briefly today. Here are the results:
I'll dig into it. Haven't looked into the volume normalization yet; but I see log messages saying
Which sounds like it might be the culprit; I might've rigged something up badly. |
Alright:
The problem here was indeed what @busimus mentioned here:
Re this:
@busimus, what do you mean by "right" in this case? I'm not super familiar with dbus, but my understanding is that playerctl chooses arbitrarily unless you have playerctld running. I'm not sure how Final DBUS regression:
This was something gnarly to do with futures / async/await that I don't quite understand, but I've added a hack to workaround it. |
Alright, fix for normalization is in too. |
This was probably me forgetting that I wrote many workarounds to make it work right. I guess the dream is that
I wish I could say I remembered to disable normalization when I started testing new changes before that commit. But it did fix it. |
FWIW, I think the issues with play-pause being slow to respond are actually not in the DBUS implementation; it's got something to do with the way frames are buffered in ALSA. I've been using the Rodio backend on OSX and it's been very responsive, at least. There are additional issues with other MPRIS methods requiring a server round trip -- notably, the |
I'm using the pulseaudio backend and it stops fast enough if I use I tested that branch. Getting metadata or playback status is instantaneous but strangely enough
So, if you manage to speed up |
Ah, I think I know what's going on -- Thanks for the repro command, that's super helpful! I think I'll open an issue with librespot and ask them if they've got ideas for fetching Loop/Shuffle status, but I'm also inclined to say "let's not worry about it for this PR and do it in the future given that it's not a regression." |
Yeah you're right. EDIT: Or does it require a workaround? I compiled in release mode and suddenly playrctld doesn't throw any warnings and |
I tested that debug/release mode race condition a bit. It happens in the exact same way both in this PR and in the other branch: in debug mode playerctld throws the warning and ignores spotifyd, in release mode warnings happen rarely and when they don't then playerctl works perfectly (but slowly in this PR). In case you need them, here are |
Cargo.toml
Outdated
url = "1.7" | ||
xdg = "2.2" | ||
librespot = { version = "0.1.5", default-features = false, features = ["with-tremor"] } | ||
librespot = { version = "0.2.0", default-features = false, features = ["with-tremor"] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
spotifyd should depend on librespot's individual crates (e.g. librespot-audio
or librespot-connect
), since the librespot
crate is a binary and has a lot of dependencies spotifyd doesn't use, like miow
, getopts
, rpassword
and sockets2
.
See #951
This would be a huge update 🥳 thanks! |
I've been using this branch for a little while now. It works very well. |
Amazing update! its a little much code to review right now, but ill try and test it this week. Eventhough it introduces some TODO's i think we should merge and maybe see to those at a later time |
… smaller libraries
We now just need 2 maintainers to approve the pr |
Hmm, still a bunch of lint checks / CI Failures; I'll see if I can work through them this weekend. |
Alright, after a bunch of messing around, I've finally got all the checks passing 😅 There's one change I was a little suspicious about -- changing the capitalisation of TV, AVR, and STB in f86275a to make clippy happy. I tested that with a config file on my local machine, and the values still deserialize correctly. |
Something I noticed when I worked with your changes: I think you can make the |
Thank you for this work! This looks pretty good to me. A few TODOs left, but I agree with @robinvd, they can be dealt with later. I'll go ahead and merge. |
Ouch, I only reviewed the code, and missed the 13 commits. In retrospect, we probably should have squashed those before merging... :) |
This is an initial attempt at upgrading librespot to 0.2.0. That also required:
dbus_mpris.rs
to usedbus-crossroads
.The dbus-mpris stuff was all written using an older version of
dbus-rs
, which integrated with tokio 0.1, and therefore needed to be upgraded. I initially tried to do this with thedbus-tree
package to minimise code changes, but I found it difficult to reason about the threading model, and eventually switched to dbus-crossroads. I hope that's ok!I've left a number of TODOs in the code:
I'd love some input on how to resolve those!
Fixes #969