[PR #1176] [MERGED] Use a single player instance #1264

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

📋 Pull Request Information

Original PR: https://github.com/librespot-org/librespot/pull/1176
Author: @jlehtoranta
Created: 6/13/2023
Status: Merged
Merged: 7/19/2023
Merged by: @roderickvd

Base: devHead: single-player


📝 Commits (8)

  • 46195f1 Handle play_request_id as an event
  • ddadcc9 Add a health check method to player
  • c6b62b8 Allow player session changes
  • e3db099 Use single player and mixer instances
  • e5abed7 Exit with an error when the player instance is invalid
  • 02c9be3 Reset session after spirc crash
  • c60c4f4 Start a new session on credentials change
  • b1c6641 Update changelog (#1176)

📊 Changes

8 files changed (+100 additions, -51 deletions)

View changed files

📝 CHANGELOG.md (+3 -0)
📝 connect/src/spirc.rs (+11 -5)
📝 examples/play.rs (+1 -1)
📝 examples/play_connect.rs (+2 -1)
📝 playback/src/mixer/mod.rs (+6 -4)
📝 playback/src/player.rs (+32 -18)
📝 src/main.rs (+41 -22)
📝 src/player_event_handler.rs (+4 -0)

📄 Description

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.


🔄 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/1176 **Author:** [@jlehtoranta](https://github.com/jlehtoranta) **Created:** 6/13/2023 **Status:** ✅ Merged **Merged:** 7/19/2023 **Merged by:** [@roderickvd](https://github.com/roderickvd) **Base:** `dev` ← **Head:** `single-player` --- ### 📝 Commits (8) - [`46195f1`](https://github.com/librespot-org/librespot/commit/46195f18d6d2d55f7b5c296422e48d80ed259609) Handle play_request_id as an event - [`ddadcc9`](https://github.com/librespot-org/librespot/commit/ddadcc9ea050d33115e2fee5039481c63b0706cc) Add a health check method to player - [`c6b62b8`](https://github.com/librespot-org/librespot/commit/c6b62b82d411b54b79d4cc69c66da9e6a9abbc7b) Allow player session changes - [`e3db099`](https://github.com/librespot-org/librespot/commit/e3db0994bce1379521b4b3aeef601b4b649e7315) Use single player and mixer instances - [`e5abed7`](https://github.com/librespot-org/librespot/commit/e5abed7c9286abac0849273642c69039acced5ec) Exit with an error when the player instance is invalid - [`02c9be3`](https://github.com/librespot-org/librespot/commit/02c9be368da7460379ab22421ee28a4d259e398b) Reset session after spirc crash - [`c60c4f4`](https://github.com/librespot-org/librespot/commit/c60c4f4c8c52ae94c0c6e5096961c802886ddcbd) Start a new session on credentials change - [`b1c6641`](https://github.com/librespot-org/librespot/commit/b1c66417234fe5e5031d83744fb297b235c1b33c) Update changelog (#1176) ### 📊 Changes **8 files changed** (+100 additions, -51 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+3 -0) 📝 `connect/src/spirc.rs` (+11 -5) 📝 `examples/play.rs` (+1 -1) 📝 `examples/play_connect.rs` (+2 -1) 📝 `playback/src/mixer/mod.rs` (+6 -4) 📝 `playback/src/player.rs` (+32 -18) 📝 `src/main.rs` (+41 -22) 📝 `src/player_event_handler.rs` (+4 -0) </details> ### 📄 Description 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. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-27 20:01:47 +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#1264
No description provided.