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