You are not logged in.

#1 2025-04-26 16:18:24

colorglass
Member
Registered: 2024-09-21
Posts: 4

pipewire-alsa bind the virtual mute state to real Speaker

Hi, I recently moved to use pipewire-alsa for ALSA audio control and then I got some issues.
I'm using a laptop with a built-in Speaker and a Headphone port within same sound card.

colorglass@archlinux ~> amixer -c2
Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 87
  Mono: Playback 49 [56%] [-28.50dB] [on]
Simple mixer control 'Headphone',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 87
  Mono:
  Front Left: Playback 87 [100%] [0.00dB] [on]
  Front Right: Playback 87 [100%] [0.00dB] [on]
Simple mixer control 'Speaker',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 87
  Mono:
  Front Left: Playback 87 [100%] [0.00dB] [on]
  Front Right: Playback 87 [100%] [0.00dB] [on]
Simple mixer control 'PCM',0
  Capabilities: pvolume
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 255
  Mono:
  Front Left: Playback 255 [100%] [0.00dB]
  Front Right: Playback 255 [100%] [0.00dB]
Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 63
  Front Left: Capture 63 [100%] [30.00dB] [on]
  Front Right: Capture 63 [100%] [30.00dB] [on]
Simple mixer control 'Auto-Mute Mode',0
  Capabilities: enum
  Items: 'Disabled' 'Enabled'
  Item0: 'Disabled'
Simple mixer control 'Headset Mic',0
  Capabilities: cswitch cswitch-joined cswitch-exclusive
  Capture exclusive group: 0
  Capture channels: Mono
  Mono: Capture [off]
Simple mixer control 'Headset Mic Boost',0
  Capabilities: volume
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 3
  Front Left: 0 [0%] [0.00dB]
  Front Right: 0 [0%] [0.00dB]
Simple mixer control 'Internal Mic',0
  Capabilities: cswitch cswitch-joined cswitch-exclusive
  Capture exclusive group: 0
  Capture channels: Mono
  Mono: Capture [on]
Simple mixer control 'Internal Mic Boost',0
  Capabilities: volume
  Playback channels: Front Left - Front Right
  Capture channels: Front Left - Front Right
  Limits: 0 - 3
  Front Left: 3 [100%] [30.00dB]
  Front Right: 3 [100%] [30.00dB]

When using only the ALSA interface, I can use amixer to manually control the mute state of the Speaker and Headphone when the Headphone is plugged in. So that I can switch the sound playing from between Speaker and Headphone.

Here to disable Speaker and only use Headphone

colorglass@archlinux ~> amixer -c2 sset Speaker toggle
Simple mixer control 'Speaker',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 87
  Mono:
  Front Left: Playback 87 [100%] [0.00dB] [off]
  Front Right: Playback 87 [100%] [0.00dB] [off]
colorglass@archlinux ~> amixer -c2
Simple mixer control 'Master',0
  Capabilities: pvolume pvolume-joined pswitch pswitch-joined
  Playback channels: Mono
  Limits: Playback 0 - 87
  Mono: Playback 49 [56%] [-28.50dB] [on]
Simple mixer control 'Headphone',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 87
  Mono:
  Front Left: Playback 87 [100%] [0.00dB] [on]
  Front Right: Playback 87 [100%] [0.00dB] [on]
Simple mixer control 'Speaker',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 87
  Mono:
  Front Left: Playback 87 [100%] [0.00dB] [off]
  Front Right: Playback 87 [100%] [0.00dB] [off]

To disable Headphone and use Speaker:

colorglass@archlinux ~> amixer -c2 sset Speaker toggle
Simple mixer control 'Speaker',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 87
  Mono:
  Front Left: Playback 87 [100%] [0.00dB] [on]
  Front Right: Playback 87 [100%] [0.00dB] [on]
colorglass@archlinux ~> amixer -c2 sset Headphone toggle
Simple mixer control 'Headphone',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 87
  Mono:
  Front Left: Playback 87 [100%] [0.00dB] [off]
  Front Right: Playback 87 [100%] [0.00dB] [off]

Then when I enabled the pipewire alsa service it create a virtual ALSA device which replace my real card to handle audio.

colorglass@archlinux ~> amixer
Simple mixer control 'Master',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 65536
  Mono:
  Front Left: Playback 21952 [33%] [on]
  Front Right: Playback 21952 [33%] [on]
Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch cswitch-joined
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 65536
  Front Left: Capture 65536 [100%] [on]
  Front Right: Capture 65536 [100%] [on]

But this time when I use the amxier to toggle the mute state of Spaker and Headphone, the mute state of "Pipewire" follows the Headphone. Therefore when I want to switch from Headphone to Speaker, the "Pipewire" get muted and no sound play.

colorglass@archlinux ~> amixer
Simple mixer control 'Master',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 65536
  Mono:
  Front Left: Playback 21952 [33%] [on]
  Front Right: Playback 21952 [33%] [on]
Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch cswitch-joined
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 65536
  Front Left: Capture 65536 [100%] [on]
  Front Right: Capture 65536 [100%] [on]
colorglass@archlinux ~> amixer -c2 sset Headphone toggle
Simple mixer control 'Headphone',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 87
  Mono:
  Front Left: Playback 87 [100%] [0.00dB] [off]
  Front Right: Playback 87 [100%] [0.00dB] [off]
colorglass@archlinux ~> amixer
Simple mixer control 'Master',0
  Capabilities: pvolume pswitch pswitch-joined
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 65536
  Mono:
  Front Left: Playback 21952 [33%] [off]
  Front Right: Playback 21952 [33%] [off]
Simple mixer control 'Capture',0
  Capabilities: cvolume cswitch cswitch-joined
  Capture channels: Front Left - Front Right
  Limits: Capture 0 - 65536
  Front Left: Capture 65536 [100%] [on]
  Front Right: Capture 65536 [100%] [on]
colorglass@archlinux ~> amixer -c2 sget Speaker
Simple mixer control 'Speaker',0
  Capabilities: pvolume pswitch
  Playback channels: Front Left - Front Right
  Limits: Playback 0 - 87
  Mono:
  Front Left: Playback 87 [100%] [0.00dB] [on]
  Front Right: Playback 87 [100%] [0.00dB] [on]

And when I unmute the "Pipewire", the Headphone is unmuted too causing the Speaker and Headphone play sound in the same time.
Is there any way to make "Pipewire" to not to bind it's mute state to only one of the real outputs, so that I can switch between Speaker and Headphone as in Windows system. Thanks big_smile

Offline

#2 2025-04-26 23:20:14

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,157

Re: pipewire-alsa bind the virtual mute state to real Speaker

You'd normally configure your volumes in something that's "pipewire/pulse aware" like pactl/pavucontrol which will usually have distinct profiles for headphone/speaker that will relevantly toggle this when switching between the profiles. Have you tested that approach yet?

Online

#3 2025-04-27 11:23:11

colorglass
Member
Registered: 2024-09-21
Posts: 4

Re: pipewire-alsa bind the virtual mute state to real Speaker

Sorry for my late reply.
I installed pavucontrol and pipewire-pulse. With pavucontrol, I can see the selection between Speaker(unavailable) and Headphone in the Output Devices page and the profile of my sound card is Analog Stereo Duplex. Here the sound play only apply to the Headphone selection, and there is no sound when I chose the Speaker(unavailable).
And there is no selection box in Output Devices page when I switch profile to Pro Audio. But here I can manually toggle the mute state of Speaker and Headphone in each.
Now it seems to fix by using Pro Audio profile. But I wander how can I use the pavucontrol or some other volume panels to easily switch the output device, since it works when using pulseaudio-alsa as audio server, or I have to write some scripts to bind some keys manually.

Offline

Board footer

Powered by FluxBB