35

When adding a USB device to my system (I deliberately run no modern stack for device detection), Pulseaudio can't pickup it without restart (pulseaudio -k; pulseaudio --start).

Is there an option for, say, pactl, which will make pulseaudio to "detect" and start using newly plugged in devices?

kagali-san
  • 1,724
  • 4
  • 19
  • 32
  • I'm confused how udev, which has been around since 2005, is too modern, and yet pulseaudio is fine... And given that udev doesn't even _do_ device detection (the kernel does), "no modern stack for device detection" would kinda imply a kernel with no USB support. – u1686_grawity Nov 27 '14 at 12:35
  • I'm not sure if I understood your question properly. The matter involving auto detection of audio devices (and possibly selecting the correct profile) seems to be solved once for all in Debian Buster: you simply say what is the default input/output devices you prefer and once connected Pulseaudio switches to those devices. If you are using something a bit older, you can try https://gist.github.com/pylover/d68be364adac5f946887b85e6ed6e7ae – Richard Gomes May 27 '18 at 09:07
  • You may (or may not) find this useful: https://superuser.com/questions/1324152/bluetooth-headset-fails-to-connect-on-linux/1324154#1324154 – Richard Gomes May 27 '18 at 09:08
  • I know this is a couple years old, but I'm running into similar issues. Does the device show up in `/proc/asound`? – richardpringle Jan 07 '21 at 22:02

3 Answers3

45

Actually, yes, there is a way to do so without restarting Pulseaudio:

pacmd unload-module module-udev-detect && pacmd load-module module-udev-detect

I use it everytime I plug in my external-soundcard or after waking up my laptop. Pulseaudio cleans up his room and bring back my Spotify music on my external soundcard automatically (as it is my default soundcard).

You will need pacmd to do so; it is included in the pulseaudio-utils package on Ubuntu.

Signez
  • 565
  • 5
  • 4
  • Sometimes works sometimes not. I guess it's a fully correct answer anyway. – Stéphane Gourichon Jun 13 '17 at 12:00
  • My Ubuntu 18.04 system on a Dell Latitude E5470 rarely loses the audio device after wake-up from suspend, but when it does, this command fixes it. – Quolonel Questions Oct 09 '19 at 13:19
  • This has been the only thing that has worked after loosing output devices after suspend, without rebooting. – Justin Apr 17 '20 at 15:54
  • Also works beautifully on Linux Mint that usually loses my HDMI audio output device upon suspend nowadays, since I added an HDMI switch between my monitor and pc. Anyhow, the command does instantly add it back to the list of devices in "Sound Settings". I saved it in /etc/pm/sleep.d to be executed automatically upon resume, it seems to be working (unless I didn't suspend long enough, will see tomorrow). – Ronny D'Hoore Jun 12 '20 at 16:19
  • Interesting. Seems to be working and still valid in 2020 with KDE Neon. I have a question though, is it possible to run this as a command on USB plug/unplug? I have a Corsair VOID Pro Elite headset which goes nuts when I dualboot, so sometimes I have audio, sometimes I don't, but when I ran this command it worked beautifully. I even tried to replug the dongle and it didn't work until I ran this command. – DARKGuy Sep 18 '20 at 08:48
  • The list returned by "pacmd list-sinks" grows larger and larger each time I run the command in your answer. Is it possible to scan for audio devices without adding new sinks to the list? – kas Nov 01 '20 at 19:30
  • I provided an answer to this question because I found out how to restart PulseAudio in Ubuntu 20. – kas Nov 01 '20 at 19:42
  • This works, and it now seems to be necessary since upgrading to 20.04. For some reason PulseAudio intermittently fails to re-initialize the HDMI audio device for my TV after turning it off/on and I get a "Dummy Output" device instead. This answer allows me to write a short script and bind it to SSH Button on my tablet ("Zap HDMI audio") – Coder Guy May 31 '21 at 17:42
18

Running

pulseaudio -k && pactl load-module module-detect

worked for me. This will restart pulseaudio and therefore forget existing devices. Afterwards it will rescan for devices. The difference here is not to use udev, maybe there is an issue with the setup that prevents udev support.

This was necessary for me, as I'm using external devices at my laptop, but sometimes internal speakers.

For some reason you might need to add a sleep between both commands.

Daniel
  • 281
  • 2
  • 5
5

You're not restarting PulseAudio correctly. The correct way to restart PulseAudio in Ubuntu 20 is with this command:

systemctl --user restart pulseaudio

Restarting PulseAudio will detect new audio devices.

kas
  • 334
  • 4
  • 7