Don't create streaming connections for non-streaming instances #371
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes an issue I've been having for a little while.
For context: I'm running spotify_player in daemon mode with
enable_streaming = "DaemonOnly"
, and another instance to control the daemon.From time to time, however, things get weird, with several devices with the same name showing in the UI. This typically happens after my laptop goes to sleep and wakes up on a different wifi network.
The reason is that during the app init,
enable_streaming
is correctly checked againstis_daemon
, but isn't checked again when the session needs to be restarted. So, when the TUI recreates a session, it also creates a new streaming connection, resulting in 2 devices with the same name in the UI, and no way to tell them apart and know if the TUI or the daemon was actually used.To fix this, I moved the
is_daemon
bool tostate
, added a helper to checkenable_streaming
againstis_daemon
correctly, and used it everywhere it's required. I've been running this for several days without having this issue again.Did that before #370, so there was an extra place where
is_streaming_enabled()
was needed, but I don't think this will change anything.