librespot-org / librespot

Open Source Spotify client library
MIT License
4.52k stars 545 forks source link

Use a single player instance #1176

Closed jlehtoranta closed 1 year ago

jlehtoranta commented 1 year ago

Create a single player instance, when librespot starts and keep it running over reconnections. In the current implementation the player is recreated on every reconnection, which causes the output device to be recreated too. This creates a racing condition in Jack, which occasionally causes the output device to be created with a different name. This is an issue especially when using Jack's custom routing. I.e. A different user connects via Spotify Connect and Jack doesn't create the configured audio route because of the name change.

roderickvd commented 1 year ago

Sorry for the delay, this looks like a good catch and neat implementation. Would you add a changelog entry for this fix? Looks good to merge after!

roderickvd commented 1 year ago

Kind nudge to @jlehtoranta - could you add a changelog entry so we can merge this?

jlehtoranta commented 1 year ago

Kind nudge to @jlehtoranta - could you add a changelog entry so we can merge this?

Thanks for your comments and sorry for the delay. This is now rebased and a changelog entry has been added. I added it under "Changed", since this is more of a behaviour change rather than a simple bug fix

roderickvd commented 1 year ago

Excellent, thank you very much.

aykevl commented 1 year ago

I'm not sure whether that was intended, but it appears that this PR improved connection stability slightly (see https://github.com/Spotifyd/spotifyd/issues/1211 for details) so thanks for that :)