snapcast icon indicating copy to clipboard operation
snapcast copied to clipboard

Volume is set to 0 after mute/unmute in pipewire

Open chatziko opened this issue 8 months ago • 0 comments

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

  1. Mute a client (that uses pipewire/wireplumber) while playing.
    The stream's volume in pipewire becomes 0.

  2. Wait a few seconds for the stream to close

  3. 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,
    },
  },
}

chatziko avatar Oct 07 '23 22:10 chatziko