snapcast
snapcast copied to clipboard
Volume is set to 0 after mute/unmute in pipewire
Describe the bug
Since #931 snapclient closes the pulseaudio stream when the client is muted. However, when pipewire is used, wireplumber restores the stream's volume when it is reopened. This has the side effect of incorrectly restoring the volume to 0.
Steps to Reproduce
-
Mute a client (that uses pipewire/wireplumber) while playing.
The stream's volume in pipewire becomes 0. -
Wait a few seconds for the stream to close
-
Unmute. The stream is reopened, but wireplumber restores its volume to 0.
I'm not sure wether this should be considered a bug in snapclient or in wireplumber (see the workaround below). Maybe when we reopen the stream we can explicitly set the volume to avoid wireplumber restoring it?
Moreover when the client is muted it woud be preferable to mute the pulseaudio stream instead of setting its volume to 0. This could potentially fix the problem (it's possible that wireplumber restores the volume but not the muted flag).
Workaround
Edit ~/.config/wireplumber/main.lua.d/40-stream-defaults.lua
(copy from /usr/share/wireplumber/...
if not exists), adding the following config, which disables restoring the volume for snapcast clients.
stream_defaults.rules = {
{
matches = {
{
{ "application.name", "matches", "Snapcast" },
},
},
apply_properties = {
["state.restore-props"] = false,
},
},
}