After some debugging, I ended up doing strace on the pulseaudio server to see if I could spot the issue and I think this is the closest I got (in the attachment there's a bit more info):
write(5, "W", 1) = 1 read(16, "\0\0\0\0\1\0\0\0(\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0Front He"..., 72) = 72 ioctl(16, SNDRV_CTL_IOCTL_ELEM_READ, 0x7fff1d114f40) = 0 write(5, "W", 1) = 1 write(19, "\1\0\0\0\0\0\0\0", 8) = 8 futex(0x561a8db98540, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY) = 0 write(19, "\1\0\0\0\0\0\0\0", 8) = 8 futex(0x561a8db98540, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY) = -1 EAGAIN (Resource temporarily unavailable) write(19, "\1\0\0\0\0\0\0\0", 8) = 8 futex(0x561a8db98540, FUTEX_WAIT_BITSET_PRIVATE|FUTEX_CLOCK_REALTIME, 0, NULL, FUTEX_BITSET_MATCH_ANY) = 0 read(16, "\0\0\0\0\1\0\0\0\v\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0Headphon"..., 72) = 72 ioctl(16, SNDRV_CTL_IOCTL_ELEM_READ, 0x7fff1d114880) = 0 ioctl(16, SNDRV_CTL_IOCTL_ELEM_READ, 0x7fff1d114890) = 0 read(16, "\0\0\0\0\1\0\0\0\n\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0Headphon"..., 72) = 72 ioctl(16, SNDRV_CTL_IOCTL_ELEM_READ, 0x7fff1d114880) = 0 ioctl(16, SNDRV_CTL_IOCTL_ELEM_READ, 0x7fff1d114890) = 0 read(16, "\0\0\0\0\1\0\0\0\5\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0Surround"..., 72) = 72 ioctl(16, SNDRV_CTL_IOCTL_ELEM_READ, 0x7fff1d114880) = 0 ioctl(16, SNDRV_CTL_IOCTL_ELEM_READ, 0x7fff1d114890) = 0 read(16, "\0\0\0\0\1\0\0\0\10\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0Center P"..., 72) = 72 ioctl(16, SNDRV_CTL_IOCTL_ELEM_READ, 0x7fff1d114880) = 0 ioctl(16, SNDRV_CTL_IOCTL_ELEM_READ, 0x7fff1d114890) = 0 read(16, "\0\0\0\0\1\0\0\0\t\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0LFE Play"..., 72) = 72 ioctl(16, SNDRV_CTL_IOCTL_ELEM_READ, 0x7fff1d114880) = 0 ioctl(16, SNDRV_CTL_IOCTL_ELEM_READ, 0x7fff1d114890) = 0 read(16, "\0\0\0\0\1\0\0\0\4\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0Surround"..., 72) = 72 ioctl(16, SNDRV_CTL_IOCTL_ELEM_READ, 0x7fff1d114880) = 0 ioctl(16, SNDRV_CTL_IOCTL_ELEM_READ, 0x7fff1d114890) = 0 read(16, "\0\0\0\0\1\0\0\0\6\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0Center P"..., 72) = 72 ioctl(16, SNDRV_CTL_IOCTL_ELEM_READ, 0x7fff1d114880) = 0 ioctl(16, SNDRV_CTL_IOCTL_ELEM_READ, 0x7fff1d114890) = 0 read(16, "\0\0\0\0\1\0\0\0\7\0\0\0\2\0\0\0\0\0\0\0\0\0\0\0LFE Play"..., 72) = 72 ioctl(16, SNDRV_CTL_IOCTL_ELEM_READ, 0x7fff1d114880) = 0 ioctl(16, SNDRV_CTL_IOCTL_ELEM_READ, 0x7fff1d114890) = 0 read(16, 0x7fff1d115520, 72) = -1 EAGAIN (Resource temporarily unavailable) read(4, "WW", 10) = 2 write(5, "W", 1) = 1 write(5, "W", 1) = 1 read(4, "WW", 10) = 2 write(46, "\1\0\0\0\0\0\0\0", 8) = 8 Note that the FD 16 is "16u CHR 116,16 0t0 20030 /dev/snd/controlC1", basically the control interface of the card I really want to be listening to: card 1; the other card (0) is the one in the video card which I don't really care ** Attachment added: "lsof+strace.tar.gz" https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/1871414/+attachment/5349096/+files/lsof+strace.tar.gz -- You received this bug notification because you are a member of Desktop Packages, which is subscribed to pulseaudio in Ubuntu. https://bugs.launchpad.net/bugs/1871414 Title: Pulseaudio incorrectly detects a headphone being plugged in Status in pulseaudio package in Ubuntu: New Bug description: Software details: Distro: Kubuntu 20.04 Beta Kernel: 5.4.0-21-generic alsa-base version 1.0.25+dfsg-0ubuntu5 alsa-utils version 1.2.2-1ubuntu1 pulseaudio version 1:13.99.1-1ubuntu1 Hardware details: Motherboard: Gigabyte GA-AB350M-D3H Audio Codec: Realtek ALC887 GPU: Nvidia RTX 2060 Super (with the audio output disabled in PulseAudio) Regarding the issue: Every time I start an audio stream (regardless of the application), I can hear interruptions in the sound and when opening alsamixer I can also see the interface kind of flickering for a few milliseconds. After running pulseaudio with logging enabled for a few seconds (while playing music), this pattern can be seen: [pulseaudio] sink.c: alsa_output.pci-0000_0a_00.3.analog-stereo: state: IDLE -> RUNNING D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now plugged in D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status yes D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now unplugged D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status no D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now plugged in D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status yes D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now unplugged D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status no D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now plugged in D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status yes D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now unplugged D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status no D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now plugged in D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status yes D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now unplugged D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status no D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now plugged in D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status yes D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now unplugged D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status no D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now plugged in D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status yes D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now unplugged D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status no D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now plugged in D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status yes D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now unplugged D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status no D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now plugged in D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status yes D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now unplugged D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status no D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now plugged in D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status yes D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now unplugged D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status no D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now plugged in D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status yes D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now unplugged D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status no D: [pulseaudio] module-alsa-card.c: Jack 'Front Headphone Jack' is now plugged in D: [pulseaudio] device-port.c: Setting port analog-output-headphones to status yes Note: I've no headphones attached ! Only the line out is connected to a 2.1 Speaker It seems basically the same bug as this: https://bbs.archlinux.org/viewtopic.php?id=147225 but in my case disabling "module-switch-on-port-available" doesn't remove the audio "artifacts" To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/pulseaudio/+bug/1871414/+subscriptions -- Mailing list: https://launchpad.net/~desktop-packages Post to : [email protected] Unsubscribe : https://launchpad.net/~desktop-packages More help : https://help.launchpad.net/ListHelp

