spotify-player: widen startup device-connect retry window

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
rope 2026-08-14 20:14:32 +01:00
parent 649c153a65
commit 3985e55ae4

View file

@ -74,24 +74,20 @@ in
inherit src; inherit src;
hash = "sha256-CSZ5sZ+d7Jhi43ipaWXKupYPFgWCbCx4RMTQN8emu9o="; hash = "sha256-CSZ5sZ+d7Jhi43ipaWXKupYPFgWCbCx4RMTQN8emu9o=";
}; };
# Always claim playback on our own device at launch, instead of having to # Give initialize_playback's retry loop a much longer window, so we don't
# pick it from the device popup every time. Two upstream guards in # have to pick our own device from the popup on every launch. Upstream
# client/mod.rs stop that from happening: # retries the transfer 5 times, once a second; our librespot device isn't
# 1. initialize_playback skips connecting entirely if any playback # registered with the Spotify backend until ~20s after startup, so all
# already exists — a phone or web player holding a paused playback # five attempts 404 and it gives up:
# is enough. # Trying to connect to device (id=…)
# 2. find_available_device returns the currently *active* device before # Connection failed (device_id=…): http error: status code 404 Not Found
# it ever gets to the "prefer the integrated device" branch. # The loop breaks on the first success, so a bigger bound costs nothing.
# Disabling both leaves the integrated device as the startup target. # The CLI is no help here: `connect --name` resolves names against the Web
# The CLI can't do this from the outside: `connect --name` resolves names # API device list, which doesn't contain the integrated device at all.
# against the Web API device list, which usually doesn't contain our
# freshly registered librespot device at all.
postPatch = (old.postPatch or "") + '' postPatch = (old.postPatch or "") + ''
substituteInPlace spotify_player/src/client/mod.rs \ substituteInPlace spotify_player/src/client/mod.rs \
--replace-fail "if state.player.read().playback.is_some() {" \ --replace-fail " for _ in 0..5 {" \
"if false {" \ " for _ in 0..60 {"
--replace-fail "if let Some(d) = devices.iter().find(|d| d.is_active) {" \
"if let Some(d) = devices.iter().find(|d| false && d.is_active) {"
''; '';
}); });
settings = { settings = {