mirror of
https://github.com/librespot-org/librespot.git
synced 2026-04-27 08:15:50 +03:00
[GH-ISSUE #1450] ALSA Mixer doesn't reflect changed volume from ALSA in librespot #653
Labels
No labels
A-Alsa
SpotifyAPI
Tokio 1.0
audio
bug
can't reproduce
compilation
dependencies
duplicate
enhancement
good first issue
help wanted
high priority
imported
imported
invalid
new api
pull-request
question
reverse engineering
wiki
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/librespot#653
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @aurimasniekis on GitHub (Jan 19, 2025).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/1450
Look for similar bugs
I have checked existing issues and found no similar reports about ALSA mixer volume synchronization problems.
Description
ALSA Mixer volume changes made through
alsamixeror etc are not being reflected in librespot playback volume. When adjusting the volume usingalsamixer, librespot maintains its previously set volume level instead of respecting the system's ALSA mixer volume settings.Version
How to reproduce
librespot --mixer alsaalsamixerLog
Host
Additional context
I am not a Rust developer but after a quick look into mixer code, it seems there is no API to notify
librespotwhen mixer value changes apart from polling viafn volume(&self) -> u16. It would be great to extend theMixertrait and then use ALSA'ssnd_ctl_subscribe_eventsto subscribe to events - when a volume event is received, we could notifylibrespotabout the change.@roderickvd commented on GitHub (Jan 19, 2025):
Do you mean volume in the Spotify UI? Or really that the volume level remains the same?
For the former, as far as I know there is no way to report volume to Spotify.
For the latter, are you sure that the same hardware mixer control is:
a) being used by
librespotb) being controlled through
alsamixer?Other way around; when you control ALSA volume through Spotify and have
alsamixeropen, do you see the volume inalsamixergoing up and down? If not, it is a configuration issue and you are not using the same hardware volume control.@aurimasniekis commented on GitHub (Jan 19, 2025):
Yes, I'm referring to the volume display in the
Spotify UI. The issue is one-directional:Spotify UI-> The volume changes are reflected inalsamixeralsamixer-> The volume level remains unchanged inSpotify UIRegarding the possibility of reporting volume to Spotify - this should be feasible, as hardware speakers with physical volume controls are able to report their volume changes back to the
Spotify UI. This suggests there is a mechanism for external volume changes to be communicated back to Spotify's interface.This issue becomes particularly problematic when running multiple audio applications that use the same ALSA mixer - when any of these apps change the volume through the mixer (
aslamixervolume changed), theSpotify UIremains stuck showing its previous volume value, leading to inconsistent volume indication.@roderickvd commented on GitHub (Jan 19, 2025):
That's interesting. @photovoltex you know if the
dealeroffers that option?@aurimasniekis commented on GitHub (Jan 19, 2025):
After some research, I found potentially relevant Spotify documentation that might help implement volume reporting:
SPPlaybackUpdateVolumefunction seems to be designed for exactly this purpose: reporting volume changes back to SpotifyI'm not sure if these commercial hardware APIs are directly applicable to librespot's implementation, but they indicate that Spotify's protocol does support receiving external volume updates. This could provide guidance on how to implement similar functionality in librespot.
@aurimasniekis commented on GitHub (Jan 19, 2025):
I also found this
notify_volume_changedin code base@photovoltex commented on GitHub (Jan 19, 2025):
Spot on. The dealer has the option to send the volume update to the server. The whole logic can be found in the main loop of the
spirc(https://github.com/librespot-org/librespot/blob/dev/connect/src/spirc.rs#L430). The issue is that we currently don't react on volume changes from the mixer/player in the spirc. I don't think we did that with mercury before as far as I'm aware of.So if we implement that communication, it could be easily communicated to the server :)
@roderickvd commented on GitHub (Jan 19, 2025):
Cool. Sketching that out, there'd be two parts to this:
player/mixerandspircfrom function-calling to message-sending over the already existing command channels.Any takers for a PR please mention so here.