alsa: Fix IEC958 digital output not unmuted on path activation

When selecting an HDMI/DisplayPort (IEC958) output path, the hardware
mute switch remains in kernel default state (muted), causing no audio
output despite correct software routing.

Root cause: pa_alsa_path_select() only sets mute switches when
mute_during_activation is enabled. No mixer paths enable this setting,
making the switch configuration code unreachable for IEC958 paths.

Solution: Always set mute switches to match device mute status after
path activation, regardless of mute_during_activation setting.

Testing: Added test-alsa-path-select tool to verify the fix.
- Loads mixer path and calls pa_alsa_path_select()
- Verifies switch states match expected values
- Tested on AMD Radeon HDMI and Realtek ALC257 analog

Manual verification:
- Before: IEC958 switch OFF, no audio
- After: IEC958 switch set correctly, audio works

This bug was inherited from PulseAudio's ALSA mixer path code where
HDMI path configurations lack IEC958 unmute sections.

Fixes: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3261
See-Also: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/issues/562
See-Also: 33be660e4b
See-Also: https://bugs.launchpad.net/hundredpapercuts/+bug/681996
This commit is contained in:
Daniel Nouri 2025-10-04 16:31:01 +02:00
parent df2f36ad8f
commit 32a3ffc747
3 changed files with 374 additions and 7 deletions

View file

@ -1479,13 +1479,23 @@ int pa_alsa_path_select(pa_alsa_path *p, pa_alsa_setting *s, snd_mixer_t *m, boo
if (s)
setting_select(s, m);
/* Finally restore hw mute to the device mute status. */
if (p->mute_during_activation) {
PA_LLIST_FOREACH(e, p->elements) {
if (e->switch_use == PA_ALSA_SWITCH_MUTE) {
if (element_set_switch(e, m, !device_is_muted) < 0)
return -1;
}
/* Set hw mute switches to match device mute status.
*
* When mute_during_activation is enabled, switches are temporarily muted
* during path setup to avoid pops/clicks, and this restores them.
*
* When mute_during_activation is disabled (default), switches may still be
* in their kernel default state (often muted for digital outputs like IEC958).
* We must explicitly unmute them if the device isn't muted.
*
* This ensures HDMI/DisplayPort audio (IEC958) works correctly, as these
* digital output switches default to muted in ALSA drivers but are not
* automatically enabled when the path is selected.
*/
PA_LLIST_FOREACH(e, p->elements) {
if (e->switch_use == PA_ALSA_SWITCH_MUTE) {
if (element_set_switch(e, m, !device_is_muted) < 0)
return -1;
}
}