The Hijacked Microphone
When you plug a new audio device into an Ubuntu machine—such as a USB webcam, a gaming headset, or even a Bluetooth speaker with a built-in microphone—the underlying PulseAudio (or PipeWire) server is designed to be helpful. It automatically assumes that the newest device you plugged in should become the default input or output. While this makes sense for headphones, it is disastrous for microphones. If you are preparing for a Zoom call using a high-quality XLR studio microphone and you suddenly plug in a cheap webcam, Ubuntu will automatically switch your audio input to the webcam’s terrible built-in microphone without warning you.
Disabling Automatic Port Switching
To ensure your audio routing remains exactly as you configured it and stop Ubuntu from automatically switching inputs when a new device is connected, you must disable the `switch-on-connect` module within the audio server.
If your system utilizes PulseAudio (standard on Ubuntu 22.04 and older), open your terminal (Ctrl+Alt+T) and edit the default configuration file: sudo nano /etc/pulse/default.pa. Scroll through the file until you locate the line that reads: load-module module-switch-on-connect. Place a hashtag (`#`) at the very beginning of that line to comment it out (it should look like #load-module module-switch-on-connect). Press Ctrl+O, Enter, then Ctrl+X to save and exit. Finally, restart the audio server by typing pulseaudio -k. The next time you plug in a webcam, the video will work perfectly, but your carefully selected microphone input will remain completely untouched.