[PR #1662] chore: Add ability to change player sample rate #1482

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

📋 Pull Request Information

Original PR: https://github.com/librespot-org/librespot/pull/1662
Author: @SapiensAnatis
Created: 12/19/2025
Status: 🔄 Open

Base: devHead: feature/local-files-resample


📝 Commits (3)

  • 8782b79 chore: Add ability to change player sample rate
  • 892522e feat: Skip track on failed sample rate changes
  • 1480a22 docs: Add changelog entry

📊 Changes

13 files changed (+157 additions, -36 deletions)

View changed files

📝 CHANGELOG.md (+1 -0)
📝 playback/src/audio_backend/alsa.rs (+33 -19)
📝 playback/src/audio_backend/gstreamer.rs (+4 -0)
📝 playback/src/audio_backend/jackaudio.rs (+4 -0)
📝 playback/src/audio_backend/mod.rs (+5 -0)
📝 playback/src/audio_backend/pipe.rs (+4 -0)
📝 playback/src/audio_backend/portaudio.rs (+4 -0)
📝 playback/src/audio_backend/pulseaudio.rs (+4 -0)
📝 playback/src/audio_backend/rodio.rs (+4 -0)
📝 playback/src/audio_backend/sdl.rs (+4 -0)
📝 playback/src/audio_backend/subprocess.rs (+4 -0)
📝 playback/src/decoder/symphonia_decoder.rs (+10 -15)
📝 playback/src/player.rs (+76 -2)

📄 Description

Adds the ability for the player to change its sample rate, to be able to accurately play back local files that aren't sampled at 44.1 kHz.

The functionality to change sample rate must be implemented individually by each sink. In this PR, I have only implemented support in the ALSA sink. I wanted to get some feedback on the general approach before I went and updated + tested every single sink. I may not actually be able to do every sink myself depending on if some of them have particular hardware/software requirements.

Testing this by swapping between a 48.0 kHz local file and a 44.1 kHz Spotify song appears to play back both without any distortion of sound.


🔄 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/1662 **Author:** [@SapiensAnatis](https://github.com/SapiensAnatis) **Created:** 12/19/2025 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `feature/local-files-resample` --- ### 📝 Commits (3) - [`8782b79`](https://github.com/librespot-org/librespot/commit/8782b79be13066aeadf7ed47180461e287d23393) chore: Add ability to change player sample rate - [`892522e`](https://github.com/librespot-org/librespot/commit/892522e7f21cec5c884c1bf8417f0bf99e450261) feat: Skip track on failed sample rate changes - [`1480a22`](https://github.com/librespot-org/librespot/commit/1480a2214bf35ac0c85cc58cd949940a0e2c7a59) docs: Add changelog entry ### 📊 Changes **13 files changed** (+157 additions, -36 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+1 -0) 📝 `playback/src/audio_backend/alsa.rs` (+33 -19) 📝 `playback/src/audio_backend/gstreamer.rs` (+4 -0) 📝 `playback/src/audio_backend/jackaudio.rs` (+4 -0) 📝 `playback/src/audio_backend/mod.rs` (+5 -0) 📝 `playback/src/audio_backend/pipe.rs` (+4 -0) 📝 `playback/src/audio_backend/portaudio.rs` (+4 -0) 📝 `playback/src/audio_backend/pulseaudio.rs` (+4 -0) 📝 `playback/src/audio_backend/rodio.rs` (+4 -0) 📝 `playback/src/audio_backend/sdl.rs` (+4 -0) 📝 `playback/src/audio_backend/subprocess.rs` (+4 -0) 📝 `playback/src/decoder/symphonia_decoder.rs` (+10 -15) 📝 `playback/src/player.rs` (+76 -2) </details> ### 📄 Description Adds the ability for the player to change its sample rate, to be able to accurately play back local files that aren't sampled at 44.1 kHz. The functionality to change sample rate must be implemented individually by each sink. In this PR, I have only implemented support in the ALSA sink. I wanted to get some feedback on the general approach before I went and updated + tested every single sink. I may not actually be able to do every sink myself depending on if some of them have particular hardware/software requirements. Testing this by swapping between a 48.0 kHz local file and a 44.1 kHz Spotify song appears to play back both without any distortion of sound. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
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#1482
No description provided.