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

  • How To Add Windows 7 8 10 11 to GRUB Boot List Dual Booting
  • How to configure OpenDKIM on Linux with Postfix and setup bind zonefile
  • Debian Ubuntu 10/11/12 Linux how to get tftpd-hpa server setup tutorial
  • efibootmgr: option requires an argument -- 'd' efibootmgr version 15 grub-install.real: error: efibootmgr failed to register the boot entry: Operation not permitted.
  • Apache Error Won't start SSL Cert Issue Solution Unable to configure verify locations for client authentication SSL Library Error: 151441510 error:0906D066:PEM routines:PEM_read_bio:bad end line SSL Library Error: 185090057 error:0B084009:x509 certif
  • Linux Debian Mint Ubuntu Bridge br0 gets random IP
  • redis requirements
  • How to kill a docker swarm
  • docker swarm silly issues
  • isc-dhcp-server dhcpd how to get longer lease
  • nvidia cannot resume from sleep Comm: nvidia-sleep.sh Tainted: Linux Ubuntu Mint Debian
  • zfs and LUKS how to recover in Linux
  • [error] (28)No space left on device: Cannot create SSLMutex Apache Solution Linux CentOS Ubuntu Debian Mint
  • Save money on bandwidth by disabling reflective rpc queries in Linux CentOS RHEL Ubuntu Debian
  • How to access a disk with bad superblock Linux Ubuntu Debian Redhat CentOS ext3 ext4
  • ImageMagick error convert solution - convert-im6.q16: cache resources exhausted
  • PTY allocation request failed on channel 0 solution
  • docker error not supported as upperdir failed to start daemon: error initializing graphdriver: driver not supported
  • Migrated Linux Ubuntu Mint not starting services due to broken /var/run and dbus - Failed to connect to bus: No such file or directory solution
  • qemu-system-x86_64: Initialization of device ide-hd failed: Failed to get