Pipewire-pulse initialize all outputs when it's only needed to output to one of them
Distro: Archlinux Pipewire, pipewire-alsa and pipewire-pulse packages installed at version 0.3.17-1
I noticed a two seconds delay at the start of apps which use the pulse lib, whereas they use the alsa lib, they start reproducing audio immediately without any delay. Using PIPEWIRE_DEBUG, I managed to find out why. The culprit is the Nvidia HDMI Audio output, since it takes like two seconds to "boot":
Dec 05 17:48:02 nix pipewire: audioadapter 0x562f4cb04658: add listener 0x7ffd7c4cd2b0 Dec 05 17:48:02 nix pipewire: audioadapter 0x562f4cb04658: 1073741943 id:3 Dec 05 17:48:02 nix pipewire: alsa-pcm 0x562f4c7c99e8: ALSA device open 'hdmi:1' playback Dec 05 17:48:05 nix pipewire: system 0x562f4c316e38: new fd:42 Dec 05 17:48:05 nix pipewire: channels (2 2) Dec 05 17:48:05 nix pipewire: alsa-pcm 0x562f4c7c99e8: position 0 3
Please, notice the timestamp difference, from the 02 second to the 05 one. The thing is that neither the Alsa path nor pw-play tries to "wake up" the HDMI audio output, so those reproduce audio immediately without introducing this annoying delay. The pulseaudio layer should have a way to go straight to the default output without touching any possible output first. I don't know though if HDMI audio is being reproduced, since my monitor doesn't have speakers. I'm always using my internal Intel sound card, so the pulseaudio layer initializes the HDMI, I wait two seconds and then I hear sound from my internal sound card.
I already tried to put the "off" profile for the HDMI card in the mean time through an autostart desktop file, which removes the delay actually:
[Desktop Entry] Name=HDMI Audio off Exec=/usr/bin/bash -c 'sleep 2 && /usr/bin/pactl set-card-profile "alsa_card.pci-0000:01:00.1" off' Type=Application Terminal=false StartupNotify=false X-GNOME-Autostart-enabled=true
But unfortunately this gets reverted times later. I don't know which mechanism is triggering this. I could be wrong though and it gets reverted due to anything I'm doing, but anyway, a better solution is needed. Whatever the alsa layer or pw-play are doing regarding output selection / card initialization must happen in the pulseaudio layer too. Thanks.