[PR #1356] [MERGED] Spirc: Replace Mecury with Dealer #1354

Closed
opened 2026-02-27 20:02:07 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/librespot-org/librespot/pull/1356
Author: @photovoltex
Created: 9/29/2024
Status: Merged
Merged: 12/10/2024
Merged by: @roderickvd

Base: devHead: integrate-dealer


📝 Commits (10+)

  • 736faaf dealer wrapper for eas of use
  • 1073081 improve sending protobuf requests
  • dfdfbd5 replace connect config with connect_state config
  • 2ecb8f0 start integrating dealer into spirc
  • c066c29 payload handling, gzip support
  • f8f350c put connect state consistent
  • 23107e7 formatting
  • 68728fe request payload handling, gzip support
  • e450428 expose dealer::protocol, move request in own file
  • 618473b integrate handle of connect-state commands

📊 Changes

43 files changed (+4175 additions, -1229 deletions)

View changed files

📝 CHANGELOG.md (+9 -0)
📝 Cargo.lock (+33 -2)
📝 connect/Cargo.toml (+1 -2)
connect/src/config.rs (+0 -22)
connect/src/context.rs (+0 -121)
📝 connect/src/lib.rs (+2 -2)
connect/src/model.rs (+188 -0)
📝 connect/src/spirc.rs (+958 -899)
connect/src/state.rs (+448 -0)
connect/src/state/context.rs (+415 -0)
connect/src/state/handle.rs (+65 -0)
connect/src/state/metadata.rs (+84 -0)
connect/src/state/options.rs (+88 -0)
connect/src/state/provider.rs (+66 -0)
connect/src/state/restrictions.rs (+61 -0)
connect/src/state/tracks.rs (+422 -0)
connect/src/state/transfer.rs (+146 -0)
📝 core/Cargo.toml (+2 -0)
📝 core/src/config.rs (+27 -0)
📝 core/src/connection/handshake.rs (+2 -2)

...and 23 more files

📄 Description

Initial PR Description

As suggested from @roderickvd a draft PR so i can have some community feedback and give now and then updates on the progress.

The replacement is in a working state, so the very basic do work again. There is still a lot of cleanup and re-implementing to do.

But so far what is working:

  • transferring the playback so that we are the player
    • funnily enough, transferring back isn't working yet
  • play, pause, resume, prev, next, seek
  • just general communication of our state to other clients

Previously Known Problems:

  • on the initial connection librespot doesn't appear, but if for example the volume is slightly updated, we should appear

    this might be a web-player specific problem, in the client the dealer just pops up

    • this seems to be to some degree fine? if the devices are reopend it seems to be always there, it just isn't dynamically updated.
  • if the session or spirc/dealer dies, we lose our complete ConnectState
    • it would be nice if that is preserved so we could start from that again
  • sometimes other client's forget that we are the current player
    • might be that that is already resolved, but i think i still saw that behavior not so long ago
    • update: seems to be resolved, was probably just an early development problem

What i still have to do:

  • handling the remaining request commands
    • queue handling (set_queue, add_to_queue)
    • repeat handling (set_repeating_track, set_repeating_context)
      • i didn't see these in the wild yet, so it might that they do not exists
    • context handling (update_context)
    • options handling (set_options)
      • should be related to shuffle and repeat
  • transferring the state to a different player again (stop playback if we are not active anymore)
  • resolving the context from a cold state
    • currently it works really well if the playback starts from a different device like the web-player
    • but from a cold start it's still a bit weird and not fully sorted out
    • we don't copy the player state from a running instance anymore,
    • so that we actually use the the cold state resolving/handling/transfering
  • shuffling has to be re-implemented
    • we can set restrictions for the clients getting our state
    • so for autoplay we should ignore shuffeling and just disable repeat and shuffle
  • autoplay has to be fixed
  • i added the option for track repeat, but it's not handled yet
  • i would like to remove the remaining mercury calls
    • but for that i will have to see if the dealer sendes equivalent messages/requests

I tried to keep my code clean, but if there are points that i could improve and such, i would like to here them^^

Currently Known Issues:

Fixes #19

  • the dealer does support this via the field repeating_track and set_options command

Fixes #434

  • a context is now resolved completely

Fixes #442

  • a context is now resolved completely

Fixes #701

  • the dealer does support this action via the command set_queue

Fixes #765

  • resolve context does provide the top 10 tracks and all albums in order from newest to oldest

Fixes #861

  • the next tracks are completely reworked

Fixes #1205

  • thx @PocketMiner82 for helping test :)

Fixes #1353

  • I encountered this issue during development, but after fixing everything around the uid's it seems to be fully functional now

Thx again to all people testing the branch, helps a lot :D


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/librespot-org/librespot/pull/1356 **Author:** [@photovoltex](https://github.com/photovoltex) **Created:** 9/29/2024 **Status:** ✅ Merged **Merged:** 12/10/2024 **Merged by:** [@roderickvd](https://github.com/roderickvd) **Base:** `dev` ← **Head:** `integrate-dealer` --- ### 📝 Commits (10+) - [`736faaf`](https://github.com/librespot-org/librespot/commit/736faafb4bb135458985428aba175acd643c9078) dealer wrapper for eas of use - [`1073081`](https://github.com/librespot-org/librespot/commit/10730816c4caf9cd8561089fa7920e57ca9c4365) improve sending protobuf requests - [`dfdfbd5`](https://github.com/librespot-org/librespot/commit/dfdfbd57e27ef7af0422e65006a20c73d6cad16a) replace connect config with connect_state config - [`2ecb8f0`](https://github.com/librespot-org/librespot/commit/2ecb8f06a781457710ae678bf4988cf4856047de) start integrating dealer into spirc - [`c066c29`](https://github.com/librespot-org/librespot/commit/c066c298d6165225ace0c184d11a284438e7b3cf) payload handling, gzip support - [`f8f350c`](https://github.com/librespot-org/librespot/commit/f8f350c23f8472e35b97d3ccefc8cacac596ba31) put connect state consistent - [`23107e7`](https://github.com/librespot-org/librespot/commit/23107e7fe0193690c86739b1cf2e0b828eb2694f) formatting - [`68728fe`](https://github.com/librespot-org/librespot/commit/68728fe9fc38cb7b31fd4cd4f26e523d8b3ed319) request payload handling, gzip support - [`e450428`](https://github.com/librespot-org/librespot/commit/e450428f3f0f0ca1802e7e7853c98e514c63ffd1) expose dealer::protocol, move request in own file - [`618473b`](https://github.com/librespot-org/librespot/commit/618473b6e2ae2ff113f5bfb0664eb7019f681d33) integrate handle of connect-state commands ### 📊 Changes **43 files changed** (+4175 additions, -1229 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+9 -0) 📝 `Cargo.lock` (+33 -2) 📝 `connect/Cargo.toml` (+1 -2) ➖ `connect/src/config.rs` (+0 -22) ➖ `connect/src/context.rs` (+0 -121) 📝 `connect/src/lib.rs` (+2 -2) ➕ `connect/src/model.rs` (+188 -0) 📝 `connect/src/spirc.rs` (+958 -899) ➕ `connect/src/state.rs` (+448 -0) ➕ `connect/src/state/context.rs` (+415 -0) ➕ `connect/src/state/handle.rs` (+65 -0) ➕ `connect/src/state/metadata.rs` (+84 -0) ➕ `connect/src/state/options.rs` (+88 -0) ➕ `connect/src/state/provider.rs` (+66 -0) ➕ `connect/src/state/restrictions.rs` (+61 -0) ➕ `connect/src/state/tracks.rs` (+422 -0) ➕ `connect/src/state/transfer.rs` (+146 -0) 📝 `core/Cargo.toml` (+2 -0) 📝 `core/src/config.rs` (+27 -0) 📝 `core/src/connection/handshake.rs` (+2 -2) _...and 23 more files_ </details> ### 📄 Description <details><summary>Initial PR Description</summary> <p> As suggested from @roderickvd a draft PR so i can have some community feedback and give now and then updates on the progress. The replacement is in a working state, so the very basic do work again. There is still a lot of cleanup and re-implementing to do. But so far what is working: - transferring the playback so that we are the player - funnily enough, transferring back isn't working yet - play, pause, resume, prev, next, seek - just general communication of our state to other clients Previously Known Problems: - [x] on the initial connection librespot doesn't appear, but if for example the volume is slightly updated, we should appear > this might be a web-player specific problem, in the client the dealer just pops up - this seems to be to some degree fine? if the devices are reopend it seems to be always there, it just isn't dynamically updated. - [x] if the session or spirc/dealer dies, we lose our complete ConnectState - it would be nice if that is preserved so we could start from that again - [x] sometimes other client's forget that we are the current player - ~might be that that is already resolved, but i think i still saw that behavior not so long ago~ - update: seems to be resolved, was probably just an early development problem What i still have to do: - [x] handling the remaining request commands - [x] queue handling (set_queue, add_to_queue) - [x] repeat handling (set_repeating_track, set_repeating_context) - i didn't see these in the wild yet, so it might that they do not exists - [x] context handling (update_context) - [x] options handling (set_options) - should be related to shuffle and repeat - [x] transferring the state to a different player again (stop playback if we are not active anymore) - [x] resolving the context from a cold state - ~~currently it works really well if the playback starts from a different device like the web-player~~ - ~~but from a cold start it's still a bit weird and not fully sorted out~~ - we don't copy the player state from a running instance anymore, - so that we actually use the the cold state resolving/handling/transfering - [x] shuffling has to be re-implemented - we can set restrictions for the clients getting our state - so for autoplay we should ignore shuffeling and just disable repeat and shuffle - [x] autoplay has to be fixed - [x] i added the option for track repeat, but it's not handled yet - [x] i would like to remove the remaining mercury calls - but for that i will have to see if the dealer sendes equivalent messages/requests I tried to keep my code clean, but if there are points that i could improve and such, i would like to here them^^ </p> </details> ### Currently Known Issues: - [x] podcasts/episodes don't work - see https://github.com/librespot-org/librespot/pull/1356#issuecomment-2512626032 - [x] starting a track out of "recent search" from mobile and then trying to switch back to mobile - see https://github.com/librespot-org/librespot/pull/1356#issuecomment-2509635805 - seems to get into a weird state where the mobile app is completely desynced - [ ] on mobile it can occur that librespot is seen as still playing with the current account, even tho it isn't playing - [ ] shufflling a context with multiple pages does only shuffle the first page (because initially only that page is loaded) - this is a problem for example, when shuffling an artist context Fixes #19 - the dealer does support this via the field `repeating_track` and `set_options` command Fixes #434 - a context is now resolved completely Fixes #442 - a context is now resolved completely Fixes #701 - the dealer does support this action via the command `set_queue` Fixes #765 - resolve context does provide the top 10 tracks and all albums in order from newest to oldest Fixes #861 - the next tracks are completely reworked Fixes #1205 - thx @PocketMiner82 for helping test :) Fixes #1353 - I encountered this issue during development, but after fixing everything around the uid's it seems to be fully functional now Thx again to all people testing the branch, helps a lot :D --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 20:02:07 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot#1354
No description provided.