You are not logged in.

#1 2023-10-28 09:34:18

BonnyAD9
Member
Registered: 2023-02-20
Posts: 12

[SOLVED] ALSA doesn't follow default audio output device

Hi, I have a new PC with new installation of arch. The main issue is that when I change my default output audio device it doesn't apply to ALSA.

Initially ALSA wasn't working at all. I was getting this error:

ALSA lib pcm_dmix.c:1000:(snd_pcm_dmix_open) unable to open slave

I could get it working by creating this .asoundrc file:

pcm.!default {
        type hw
        card 4
}

But than I could change the audio device only by editing the file: adding device 0 for my speakers or device 1 for my headphones.

I partially fixed that by installing pipewire-alsa. Now I don't need the .asoundrc file and audio works. I can change the audio device in KDE Plasma gui, but it doesn't apply for audio that is already playing and I cannot change the audio with pactl. It updates the selected device in gui but it doesn't affect ALSA, even when I restart the app that is playing audio.

These are the commands I use to switch audio devices with pactl:

# change to headphones:
pactl set-default-sink 'alsa_output.usb-Generic_USB_Audio-00.HiFi__hw_Audio_1_1__sink' \
    && pactl set-sink-port 'alsa_output.usb-Generic_USB_Audio-00.HiFi__hw_Audio_1_1__sink' '[Out] Headphones'

# change to speakers
pactl set-default-sink 'alsa_output.usb-Generic_USB_Audio-00.HiFi__hw_Audio_1__sink' \
    && pactl set-sink-port 'alsa_output.usb-Generic_USB_Audio-00.HiFi__hw_Audio_1__sink' '[Out] Speaker'

Everything forks perfectly fine for apps that use for example JACK.

So what I want is to make it so that pactl also changes the default audio device for ALSA and it applies immediately for currently playing audio.

Last edited by BonnyAD9 (2023-10-28 12:49:42)

Offline

#2 2023-10-28 10:40:55

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 15,102

Re: [SOLVED] ALSA doesn't follow default audio output device

BonnyAD9 wrote:

installing pipewire-alsa

https://wiki.archlinux.org/title/PipeWire#ALSA_clients wrote:

Install pipewire-alsa (and remove pulseaudio-alsa if it was installed) to route all applications using the ALSA API through PipeWire.

You're not using alsa userspace anymore, but pipewire .

BonnyAD9 wrote:

So what I want is to make it so that pactl also changes the default audio device for ALSA and it applies immediately for currently playing audio.

No idea if that's possible but alsa dmix is very powerful and pipewire can make use of it.
See https://wiki.archlinux.org/title/PipeWi … Wire_sinks for more info .

Last edited by Lone_Wolf (2023-10-28 10:43:13)


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#3 2023-10-28 12:27:30

BonnyAD9
Member
Registered: 2023-02-20
Posts: 12

Re: [SOLVED] ALSA doesn't follow default audio output device

Lone_Wolf wrote:

I tried to follow the guide there, but when I copy the default configuration from /usr/share/pipewire/pipewire.conf to ~/.config/pipewire/pipewire.conf.d/alsa-dmix.conf (without changing it), after reboot pipewire won't start and I see this in journalctl:

pipewire.service: Main process exited, code=exited, status=239/CACHE_DIRECTORY

Offline

#4 2023-10-28 12:48:43

BonnyAD9
Member
Registered: 2023-02-20
Posts: 12

Re: [SOLVED] ALSA doesn't follow default audio output device

I don't know why but now it just started working. All I did was following the guide and when it didn't work I undo everything.

While I was following the guide I installed wireplumber, so maybe it is because of that.

Thanks for your help, I'm marking this as solved.

Last edited by BonnyAD9 (2023-10-28 12:49:00)

Offline

Board footer

Powered by FluxBB