Linux Sound and USB Microphones
A few weeks ago, I was minding my own business, furiously trying to get ready for a Zoom meeting. I was moving USB sound devices around when, suddenly, without warning, Pop!_OS no longer detected my USB microphone. No sound.
Great.
Unplug from the USB hub, then plug into the computer directly. No. Unplug from the left-side USB port and plug into the right-side USB port. No. Plug into each and every port in the USB hub. No.
Great.
Reboot.
Plug in the microphone directly into the computer on the inconvenient-for-my-setup right-side USB port.
Yes! Sound!
I had my meeting over Zoom. All was well.
But what had happened?!
Recreating the Problem
Recreating the problem took a couple of weeks. I noticed this problem intermittently. My favorite! Eventually I looked straight at the error message in syslog
.
D: [pulseaudio] module-udev-detect.c: /dev/snd/controlC1 is accessible: yes
D: [pulseaudio] module-udev-detect.c: /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/sound/card1 is busy: no
D: [pulseaudio] module-udev-detect.c: Loading module-alsa-card with arguments 'device_id="1" name="usb-Blue_Microphones_Yeti_Stereo_Microphone-00" card_name="alsa_card.usb-Blue_Microphones_Yeti_Stereo_Microphone-00" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes avoid_resampling=no card_properties="module-udev-detect.discovered=1"'
D: [pulseaudio] reserve-wrap.c: Device 'Audio1' already locked.
E: [pulseaudio] module.c: Failed to load module "module-alsa-card" (argument: "device_id="1" name="usb-Blue_Microphones_Yeti_Stereo_Microphone-00" card_name="alsa_card.usb-Blue_Microphones_Yeti_Stereo_Microphone-00" namereg_fail=false tsched=yes fixed_latency_range=no ignore_dB=no deferred_volume=yes use_ucm=yes avoid_resampling=no card_properties="module-udev-detect.discovered=1""): initialization failed.
I: [pulseaudio] module-udev-detect.c: Card /devices/pci0000:00/0000:00:14.0/usb1/1-7/1-7:1.0/sound/card1 (alsa_card.usb-Blue_Microphones_Yeti_Stereo_Microphone-00) failed to load module.
I: [pulseaudio] client.c: Created 3 "Native client (UNIX socket client)"
OK. “Device X already locked.” This looks like a problem. “Failed to load module.” This looks like a problem. Fine.
Search the web.
Nothing useful.
OK.
After a few days, I could reproduce the problem reliably and I could work around the problem by rebooting. I didn’t even care about fixing the problem so much as finding a workaround that didn’t require rebooting. I wasn’t asking much.
Ask the Right Question
I asked on askubuntu
, but they told me that I was in the wrong place, because I have Pop!_OS, which is essentially Ubuntu, but not exactly Ubuntu. Fine. I moved my question to a better place.
Here is the question: https://unix.stackexchange.com/q/635813/256763
And fortunately, beautifully, I received a useful answer one day later.
Stop Pipewire. Restart pulseaudio. Gather wood. Check the traps.
$ systemctl --user stop pipewire.service
$ systemctl --user restart pulseaudio
According to Paul Medynski:
It appears to be a race between pipewire and pulseaudio. I don’t know anything about pipewire, but it sometimes seems to grab a lock on the USB audio device before pulseaudio can access it.
Fine.
$ systemctl --user disable pipewire.service
$ systemctl --user disable pipewire.socket
$ systemctl --user restart pulseaudio
And now all is well. I just tested by unplugging then plugging in my Blue Yeti microphone 6 times in 30 seconds. All is well.
I have sound.
Thank you, Paul. I appreciate you for taking the time to answer my question.