7

I have a laptop running Ubuntu 18.04 and i3wm connected via Thunderbolt to a dock and a webcam. I want that the default pulse audio sink is set to the laptops internal sound card. Thus I have

set-default-sink alsa_output.pci-0000_00_1f.3.analog-stereo
set-default-source alsa_input.pci-0000_00_1f.3.analog-stereo

in /etc/pulse/default.pa .

This does not work, the default sink is set to the dock and the default source to the webcam after boot. Pulse audio informs me that

[pulseaudio] main.c: Source alsa_input.pci-0000_00_1f.3.analog-stereo does not exist.
[pulseaudio] main.c: Sink alsa_output.pci-0000_00_1f.3.analog-stereo does not exist.

Restarting pulse audio after boot sets the default source and sink to laptops internal audio card as specified in the config. How can I debug this problem?

user3457151
  • 175
  • 1
  • 1
  • 4

1 Answers1

1

This question is not about programming, but the mods don't seem to care, so... here goes.

I've ran into a similar issue the last few days, so the below is what I've found, but your situation may be a bit different.

First off, my experience is on Ubuntu Linux systems. Pulse audio runs as a user service on Ubuntu, so the below commands related to systemd (systemctl, journalctl) will contain --user. If your pulseaudio runs as a system service, omit the --user part of the commands and prepend sudo.


Okay, so the first step to debugging pulseaudio issues is to check the log file. Assuming your pulseaudio service logs to journald, run the following command:

journalctl --user -u pulseaudio.service

Scroll to the end for the most recent log entries. You're looking for entries that say Master sink not found. If you find that, look above for an entry that says Card '0' doesn't exist: No such file or directory. If you see that, then you've run into the exact same problem I did.

If you did not find an entry saying Card '0' doesn't exist, but did find entries saying Master sink not found, then it may be that all you need to do is manually specify the sink(s) in /etc/pulse/default.pa.

To manually specify a sink, edit /etc/pulse/default.pa: sudo nano /etc/pulse/default.pa. You'll want to add lines to manually specify sinks. This depends on your hardware, so refer to the pulseaudio documentation for module-alsa-sink. There are several lines in default.pa that load modules, so refer to them for the formatting.

If you're running into the Card '0' not found issue, then keep reading.

First off, you'll probably want to go ahead and add a load module line to /etc/pulse/default.pa to go ahead and manually specify your audio card. Again, this is hardware-specific, so you'll need to refer to the pulseaudio documentation for module-alsa-card.

Depending on your situation, manually loading module-alsa-card may be enough to fix your problem. If not, then you're really running into the exact same situation as me. Congratulations, I feel your pain.

What appears to be happening here, based on my situation at least, is that the pulseaudio service is running before Alsa has had a chance to create the /dev/snd/controlC0 device node. If you got the Card '0' doesn't exist error, then according to the source code for libasound2, this error is caused by libasound2 being unable to open /dev/snd/controlC0 because it doesn't exist. I tried every which way to modify the pulseaudio.service file to wait for this device node to exist, but to no avail.

Ultimately, what I did do is I created a shell script that contains the following code in /etc/pulse/runpulse.sh:

#!/bin/bash

while [[ ! -e /dev/snd/controlC0 ]]; do
    sleep 0.5
done

sleep 1

/usr/bin/pulseaudio --daemonize=no --log-target=journal

Make sure to run sudo chown root.root /etc/pulse/runpulse.sh and sudo chmod 755 /etc/pulse/runpulse.sh.

That last line, the one that runs pulseaudio, is the line that's usually present in /usr/lib/systemd/user/pulseaudio.service for the ExecStart command. Replace everything after ExecStart= in that service file with /etc/pulse/runpulse.sh. Then, run systemctl --user daemon-reload.

You may want to go ahead and test that the service will start up: systemctl --user restart pulseaudio.service.

If the service starts/restarts successfully (check with systemctl --user status pulseaudio.service), then go ahead and reboot at this point.

Hopefully your problem is now solved, life is good, and you can now enjoy some sweet, sweet, tunes. You've earned it.

If this doesn't solve your problem, I hope at the very least I was able to provide some insight into what your issue may be and some methods of troubleshooting and/or fixing it. Best of luck to you.

Gogeta70
  • 881
  • 1
  • 9
  • 23