pulseaudio issue on QEMU/KVM guest VM when microphone is replugged/unplugged pulseaudio: pa_threaded_mainloop_lock failed pulseaudio: Reason: Invalid argument

Here is the scenario, you are using QEMU/KVM and are using something like the AC97 sound driver to pass the host audio to the guest via pulseaudio.  This is useful because you can transparently pass your mic input from the host which means you can mute your microphone from the host, which prevents the guest from receiving any mic input even if unmuted.

Mute / Unmute Fix

This issue also seems to happen even if you press the mute button on the microphone and then unmute, it has virtually the same effect as unplugging and replugging the USB microphone.

One thing that seems to help with muting and unmuting button issue, is if you set your Microphone as a single input only (no dual input/output / duplex).

In Mint/Ubuntu, it means going to Sound Settings, Hardware, clicking on your Microphone and just choosing "Input"

 

Here is the relevant CLI that makes this audio config happen that gets passed to QEMU:

-audiodev driver=pa,id=pa1,server=unix:/run/user/1000/pulse/native -device intel-hda -device AC97,audiodev=pa1

You would change the /run/user/1000 with your numeric uid which can be retrieved with id -u

But the problem is that input/mic audio will break (note that output is unaffected though) on the guest if there is any change to the pulseaudio on the host side during this time:

You will get pulseaudio errors like this:

pulseaudio: pa_threaded_mainloop_lock failed
pulseaudio: Reason: Invalid argument
pulseaudio: pa_threaded_mainloop_lock failed
pulseaudio: Reason: Invalid argument
pulseaudio: pa_threaded_mainloop_lock failed
pulseaudio: Reason: Invalid argument

 

I am not aware of any solution for this other than to hard restart the guest VM (not just a graceful reset initiated from the VM but a full hard poweroff of the VM).

One other config that I have tried is to use the -device hda-duplex but this seems to be buggy as shortly after starting the VM, mic audio input seems to fail on the guest which means the mic stops working.  This is why I use AC97, as it seems to be persistent so long as you don't unpug the microphone (config CLI below).

-audiodev driver=pa,id=pa1,server=unix:/run/user/1000/pulse/native -device intel-hda -device hda-duplex,audiodev=pa1


Tags:

pulseaudio, qemu, kvm, vm, microphone, replugged, unpluggedhere, ac, audio, via, transparently, mic, input, mute, prevents, receiving, unmuted, relevant, cli, config, audiodev, server, unix, user, native, intel, hda, numeric, uid, retrieved, output, unaffected, errors, pa_threaded_mainloop_lock, invalid, restart, graceful, reset, initiated, poweroff, duplex, buggy, persistent, unpug,

Latest Articles

  • Linux and Windows Dual Boot Issue NIC Won't work After Booting Windows
  • Cisco CME How To Enable ACD hunt groups
  • How to install gns3 on Linux Ubuntu Mint
  • How to convert audio for Asterisk .wav format
  • Using Cisco CME Router with Asterisk as a dial-peer
  • Cisco CME How To Configure SIP Trunk VOIP
  • Virtualbox host Only Network Error Failed to save host network interface parameter - Cannot change gateway IP of host only network
  • Cisco CME and C7200 Router Testing and Learning Environment on Ubuntu 20+ Setup Tutorial Guide
  • Abusive IP ranges blacklist
  • How to Install Any OS on a Physical Drive from Windows Using VMware Workstation (Linux, Windows, BSD)
  • CDN Cloudflare how to set and preserve the real IP of the client without modifying application code on Apache
  • CentOS 7 fix Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=container error was 14: curl#6 -
  • Ubuntu Debian How To Install Recommended Packages Automatically
  • How to set Linux Ubuntu Redhat Debian Command Line http https socks proxy for yum apt
  • How to resize a pdf without losing much quality in Linux Mint Ubuntu Debian Redhat Solution
  • qemu: could not load PC BIOS 'bios-256k.bin' solution
  • Proxmox How To Custom Partition During Install
  • Hyper-V Linux VM Boots to Black Screen, Storage, NIC Not Found Issues
  • Ubuntu Mint How to Fix Missing/Broken /dev and /dev/pts which causes terminal to immediately close exit and not work
  • How high can a Xeon CPU get?