Crackles, stutering in Bluetooth

Hi community

When I use my laptop bluetooth connection, I hear crackling, stuttering in every way I play music in streaming. These noise appear more frequently when I connect my battery charger. The sound also take 5-10 sec to reappear sometime when I switch from a software to another.
I don’t have these issues with my bluetooth mobile connection so I deduce it’s a pulseaudio probleme.

Here’s my laptop hardware and drivers info:

  inxi -Fazy
System:
  Kernel: 5.10.42-1-MANJARO x86_64 bits: 64 compiler: gcc v: 11.1.0 
  parameters: BOOT_IMAGE=/boot/vmlinuz-5.10-x86_64 
  root=UUID=4bc4af43-9873-4471-beda-40b887f86ab4 rw quiet apparmor=1 
  security=apparmor resume=UUID=3f0b65fb-112d-474a-a4fa-79699f6e1014 
  udev.log_priority=3 
  Desktop: Xfce 4.16.0 tk: Gtk 3.24.29 info: xfce4-panel wm: xfwm4 vt: 7 
  dm: LightDM 1.30.0 Distro: Manjaro Linux base: Arch Linux 
Machine:
  Type: Laptop System: LENOVO product: 20EQS08E00 v: ThinkPad P50 
  serial: <filter> Chassis: type: 10 serial: <filter> 
  Mobo: LENOVO model: 20EQS08E00 v: SDK0J40705 WIN serial: <filter> 
  UEFI-[Legacy]: LENOVO v: N1EET57W (1.30 ) date: 08/03/2016 
Battery:
  ID-1: BAT0 charge: 75.9 Wh (100.0%) condition: 75.9/90.1 Wh (84.2%) 
  volts: 12.8 min: 11.4 model: LGC 00NY492 type: Li-poly serial: <filter> 
  status: Full 
CPU:
  Info: Quad Core model: Intel Core i7-6820HQ bits: 64 type: MT MCP 
  arch: Skylake-S family: 6 model-id: 5E (94) stepping: 3 microcode: E2 cache: 
  L2: 8 MiB 
  flags: avx avx2 lm nx pae sse sse2 sse3 sse4_1 sse4_2 ssse3 bogomips: 43214 
  Speed: 900 MHz min/max: 800/3600 MHz Core speeds (MHz): 1: 900 2: 900 3: 900 
  4: 900 5: 900 6: 900 7: 900 8: 900 
  Vulnerabilities: Type: itlb_multihit status: KVM: VMX unsupported 
  Type: l1tf mitigation: PTE Inversion 
  Type: mds mitigation: Clear CPU buffers; SMT vulnerable 
  Type: meltdown mitigation: PTI 
  Type: spec_store_bypass 
  mitigation: Speculative Store Bypass disabled via prctl and seccomp 
  Type: spectre_v1 
  mitigation: usercopy/swapgs barriers and __user pointer sanitization 
  Type: spectre_v2 mitigation: Full generic retpoline, IBPB: conditional, 
  IBRS_FW, STIBP: conditional, RSB filling 
  Type: srbds mitigation: Microcode 
  Type: tsx_async_abort mitigation: Clear CPU buffers; SMT vulnerable 
Graphics:
  Device-1: Intel HD Graphics 530 vendor: Lenovo driver: i915 v: kernel 
  bus-ID: 00:02.0 chip-ID: 8086:191b class-ID: 0300 
  Device-2: NVIDIA GM107GLM [Quadro M2000M] vendor: Lenovo driver: nvidia 
  v: 465.31 alternate: nouveau,nvidia_drm bus-ID: 01:00.0 chip-ID: 10de:13b0 
  class-ID: 0300 
  Device-3: Lite-On Integrated Camera type: USB driver: uvcvideo bus-ID: 1-8:2 
  chip-ID: 04ca:7058 class-ID: 0e02 
  Display: x11 server: X.Org 1.20.11 driver: loaded: modesetting,nvidia 
  alternate: fbdev,intel,nouveau,nv,vesa display-ID: :0.0 screens: 1 
  Screen-1: 0 s-res: 1920x1080 s-dpi: 96 s-size: 508x285mm (20.0x11.2") 
  s-diag: 582mm (22.9") 
  Monitor-1: eDP-1 res: 1920x1080 hz: 60 dpi: 142 size: 344x194mm (13.5x7.6") 
  diag: 395mm (15.5") 
  OpenGL: renderer: Mesa Intel HD Graphics 530 (SKL GT2) v: 4.6 Mesa 21.1.2 
  direct render: Yes 
Audio:
  Device-1: Intel 100 Series/C230 Series Family HD Audio vendor: Lenovo 
  driver: snd_hda_intel v: kernel bus-ID: 00:1f.3 chip-ID: 8086:a170 
  class-ID: 0403 
  Sound Server-1: ALSA v: k5.10.42-1-MANJARO running: yes 
  Sound Server-2: JACK v: 0.125.0 running: no 
  Sound Server-3: PulseAudio v: 14.2 running: yes 
  Sound Server-4: PipeWire v: 0.3.30 running: no 
Network:
  Device-1: Intel Ethernet I219-LM vendor: Lenovo driver: e1000e v: kernel 
  port: efa0 bus-ID: 00:1f.6 chip-ID: 8086:15b7 class-ID: 0200 
  IF: enp0s31f6 state: down mac: <filter> 
  Device-2: Intel Wireless 8260 driver: iwlwifi v: kernel port: 4000 
  bus-ID: 04:00.0 chip-ID: 8086:24f3 class-ID: 0280 
  IF: wlp4s0 state: up mac: <filter> 
  IF-ID-1: pan1 state: down mac: <filter> 
Bluetooth:
  Device-1: Intel Bluetooth wireless interface type: USB driver: btusb v: 0.8 
  bus-ID: 1-14:4 chip-ID: 8087:0a2b class-ID: e001 
  Report: rfkill ID: hci0 rfk-id: 2 state: up address: see --recommends 
Drives:
  Local Storage: total: 238.47 GiB used: 16.4 GiB (6.9%) 
  SMART Message: Required tool smartctl not installed. Check --recommends 
  ID-1: /dev/sda maj-min: 8:0 vendor: Samsung model: MZNTY256HDHP-000L7 
  size: 238.47 GiB block-size: physical: 512 B logical: 512 B speed: 6.0 Gb/s 
  rotation: SSD serial: <filter> rev: 3L6Q scheme: MBR 
Partition:
  ID-1: / raw-size: 221.93 GiB size: 217.38 GiB (97.95%) used: 16.4 GiB (7.5%) 
  fs: ext4 dev: /dev/sda1 maj-min: 8:1 
Swap:
  Kernel: swappiness: 60 (default) cache-pressure: 100 (default) 
  ID-1: swap-1 type: partition size: 16.54 GiB used: 0 KiB (0.0%) priority: -2 
  dev: /dev/sda2 maj-min: 8:2 
Sensors:
  System Temperatures: cpu: 46.0 C mobo: 41.0 C 
  Fan Speeds (RPM): cpu: 0 fan-2: 0 
Info:
  Processes: 244 Uptime: 40m wakeups: 1 Memory: 15.04 GiB 
  used: 3.55 GiB (23.6%) Init: systemd v: 248 tool: systemctl Compilers: 
  gcc: 11.1.0 Packages: 1137 pacman: 1125 lib: 329 flatpak: 6 snap: 6 
  Shell: Bash v: 5.1.8 running-in: xfce4-terminal inxi: 3.3.04 

I tried to improve the settings with this help page PulseAudio/Troubleshooting - ArchWiki

Here’s my demon.conf

; daemonize = no
; fail = yes
; allow-module-loading = yes
; allow-exit = yes
; use-pid-file = yes
; system-instance = no
; local-server-type = user
; enable-shm = yes
; enable-memfd = yes
; shm-size-bytes = 0 # setting this 0 will use the system-default, usually 64 MiB
; lock-memory = no
; cpu-limit = no

; high-priority = yes
; nice-level = -11

; realtime-scheduling = yes
; realtime-priority = 9

; exit-idle-time = 20
; scache-idle-time = 20

; dl-search-path = (depends on architecture)

; load-default-script-file = yes
; default-script-file = /etc/pulse/default.pa

; log-target = auto
; log-level = notice
; log-meta = no
; log-time = no
; log-backtrace = 0

; resample-method = soxr-vhq
; avoid-resampling = yes
; enable-remixing = no
; remixing-use-all-sink-channels = yes
; remixing-produce-lfe = no
; remixing-consume-lfe = no
; lfe-crossover-freq = 0

; flat-volumes = no

; rescue-streams = yes

; rlimit-fsize = -1
; rlimit-data = -1
; rlimit-stack = -1
; rlimit-core = -1
; rlimit-as = -1
; rlimit-rss = -1
; rlimit-nproc = -1
; rlimit-nofile = 256
; rlimit-memlock = -1
; rlimit-locks = -1
; rlimit-sigpending = -1
; rlimit-msgqueue = -1
; rlimit-nice = 31
; rlimit-rtprio = 9
; rlimit-rttime = 200000

; default-sample-format = float32le
; default-sample-rate = 48000
; alternate-sample-rate = 44100
; default-sample-channels = 2
; default-channel-map = front-left,front-right

; default-fragments = 5
; default-fragment-size-msec = 2

; enable-deferred-volume = yes
; deferred-volume-safety-margin-usec = 8000
; deferred-volume-extra-delay-usec = 0

Here’s my default.pa

    #!/usr/bin/pulseaudio -nF
#
# This file is part of PulseAudio.
#
# PulseAudio is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# PulseAudio is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.

# This startup script is used only if PulseAudio is started per-user
# (i.e. not in system mode)

.fail

### Automatically restore the volume of streams and devices
load-module module-device-restore
load-module module-stream-restore
load-module module-card-restore

### Automatically augment property information from .desktop files
### stored in /usr/share/application
load-module module-augment-properties

### Should be after module-*-restore but before module-*-detect
load-module module-switch-on-port-available

### Load audio drivers statically
### (it's probably better to not load these drivers manually, but instead
### use module-udev-detect -- see below -- for doing this automatically)
#load-module module-alsa-sink
#load-module module-alsa-source device=hw:1,0
#load-module module-oss device="/dev/dsp" sink_name=output source_name=input
#load-module module-oss-mmap device="/dev/dsp" sink_name=output source_name=input
#load-module module-null-sink
#load-module module-pipe-sink

### Automatically load driver modules depending on the hardware available
.ifexists module-udev-detect.so
load-module module-udev-detect tsched=0
.else
### Use the static hardware detection module (for systems that lack udev support)
load-module module-detect
.endif

### Automatically connect sink and source if JACK server is present
.ifexists module-jackdbus-detect.so
.nofail
load-module module-jackdbus-detect channels=2
.fail
.endif

### Automatically load driver modules for Bluetooth hardware
.ifexists module-bluetooth-policy.so
load-module module-bluetooth-policy
.endif

.ifexists module-bluetooth-discover.so
load-module module-bluetooth-discover
.endif

### Load several protocols
load-module module-dbus-protocol
.ifexists module-esound-protocol-unix.so
load-module module-esound-protocol-unix
.endif
load-module module-native-protocol-unix

### Network access (may be configured with paprefs, so leave this commented
### here if you plan to use paprefs)
#load-module module-esound-protocol-tcp
#load-module module-native-protocol-tcp
#load-module module-zeroconf-publish

### Load the RTP receiver module (also configured via paprefs, see above)
#load-module module-rtp-recv

### Load the RTP sender module (also configured via paprefs, see above)
#set-default-sink rtp

### Load additional modules from GSettings. This can be configured with the paprefs tool.
### Please keep in mind that the modules configured by paprefs might conflict with manually
### loaded modules.
.ifexists module-gsettings.so
.nofail
load-module module-gsettings
.fail
.endif


### Automatically restore the default sink/source when changed by the user
### during runtime
### NOTE: This should be loaded as early as possible so that subsequent modules
### that look up the default sink/source get the right value
load-module module-default-device-restore

### Make sure we always have a sink around, even if it is a null sink.
load-module module-always-sink

### Honour intended role device property
load-module module-intended-roles

### Automatically suspend sinks/sources that become idle for too long
.nofail
unload-module module-suspend-on-idle
.fail
### If autoexit on idle is enabled we want to make sure we only quit
### when no local session needs us anymore.
.ifexists module-console-kit.so
load-module module-console-kit
.endif
.ifexists module-systemd-login.so
load-module module-systemd-login
.endif

### Enable positioned event sounds
load-module module-position-event-sounds

### Cork music/video streams when a phone stream is active
load-module module-role-cork

### Modules to allow autoloading of filters (such as echo cancellation)
### on demand. module-filter-heuristics tries to determine what filters
### make sense, and module-filter-apply does the heavy-lifting of
### loading modules and rerouting streams.
load-module module-filter-heuristics
load-module module-filter-apply

### Make some devices default
#set-default-sink output
#set-default-source input

Thanks for ypour help and sorry for my bad english ^^’

Hey, maybe something from here Bluetooth headset - ArchWiki helps you. There’s a section for Connecting works, but there are sound glitches all the time

I tried to find my bluez card id by the command below but it doesn’t find it.

$ pacmd list-cards
1 card(s) available.
    index: 0
	name: <alsa_card.pci-0000_00_1f.3>
	driver: <module-alsa-card.c>
	owner module: 6
	properties:
		alsa.card = "0"
		alsa.card_name = "HDA Intel PCH"
		alsa.long_card_name = "HDA Intel PCH at 0xc5740000 irq 132"
		alsa.driver_name = "snd_hda_intel"
		device.bus_path = "pci-0000:00:1f.3"
		sysfs.path = "/devices/pci0000:00/0000:00:1f.3/sound/card0"
		device.bus = "pci"
		device.vendor.id = "8086"
		device.vendor.name = "Intel Corporation"
		device.product.id = "a170"
		device.product.name = "100 Series/C230 Series Chipset Family HD Audio Controller"
		device.form_factor = "internal"
		device.string = "0"
		device.description = "Audio interne"
		module-udev-detect.discovered = "1"
		device.icon_name = "audio-card-pci"
	profiles:
		input:analog-stereo: Entrée Stéréo analogique (priority 65, available: unknown)
		output:analog-stereo: Sortie Stéréo analogique (priority 6500, available: unknown)
		output:analog-stereo+input:analog-stereo: Duplex stéréo analogique (priority 6565, available: unknown)
		output:analog-surround-40: Sortie Surround analogique 4.0 (priority 1200, available: unknown)
		output:analog-surround-40+input:analog-stereo: Sortie Surround analogique 4.0 + Entrée Stéréo analogique (priority 1265, available: unknown)
		off: Éteint (priority 0, available: unknown)
	active profile: <output:analog-stereo+input:analog-stereo>
	sinks:
		alsa_output.pci-0000_00_1f.3.analog-stereo/#0: Audio interne Stéréo analogique
	sources:
		alsa_output.pci-0000_00_1f.3.analog-stereo.monitor/#0: Monitor of Audio interne Stéréo analogique
		alsa_input.pci-0000_00_1f.3.analog-stereo/#1: Audio interne Stéréo analogique
	ports:
		analog-input-internal-mic: Internal Microphone (priority 8900, latency offset 0 usec, available: unknown)
			properties:
				device.icon_name = "audio-input-microphone"
		analog-input-dock-mic: Dock Microphone (priority 7800, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-input-microphone"
		analog-input-mic: Microphone (priority 8700, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-input-microphone"
		analog-output-speaker: Speakers (priority 10000, latency offset 0 usec, available: unknown)
			properties:
				device.icon_name = "audio-speakers"
		analog-output-headphones: Headphones (priority 9900, latency offset 0 usec, available: no)
			properties:
				device.icon_name = "audio-headphones"

I tried to follow the wiki arch instruction

Connecting works, but there are sound glitches all the time

This is very likely to occur when the Bluetooth and the WiFi share the same chip as they share the same physical antenna and possibly band range (2.4GHz). Although this works seamlessly on Windows, this is not the case on Linux.

A possible solution is to move your WiFi network to 5GHz so that there will be no interference. If your card/router does not support this, you can upgrade your WiFi drivers/firmware. This approach works on Realtek 8723BE and latest rtl drivers for this chip from AUR.

If nothing of the previous is possible, a less effective mitigation is to tweak the fragment size and the latency on PulseAudio output port, trying to compensate interference. Reasonable values must be chosen, because these settings can make the audio out of sync (e.g. when playing videos). To change the latency of the bluetooth headset’s port (e.g. to 125000 microseconds in the following example):

$ pactl set-port-latency-offset <bluez_card> headset-output **125000**

where the identifier of the card can be found with

$ pacmd list-sinks | egrep -o 'bluez_card[^>]*'

And it doesn’t find any bluez card.