Ubuntu 21.10 has PipeWire partially installed and enabled as it's used by browsers (WebRTC) for recoding the screeen under Wayland. We can enable remaining parts and use it for audio and Bluetooth instead of PulseAudio.
This guide is only for original Ubuntu out-of-the-box packages. If you have added a custom PPA, you might get into conflicts.
Based on the Debian Wiki, but adopted for Ubuntu 21.10.
Install Bluetooth codecs AAC/LDAC/AptX:
$ sudo apt install \
libfdk-aac2 \
libldacbt-{abr,enc}2 \
libopenaptx0
Install remaining PipeWire packages:
$ sudo apt install \
libspa-0.2-bluetooth \
pipewire-audio-client-libraries \
pipewire-pulse
Create this empty file:
$ sudo touch /usr/share/pipewire/with-alsa
Copy the config file from the PipeWire examples into your ALSA configuration directory:
$ sudo cp /usr/share/doc/pipewire/examples/alsa.conf.d/99-pipewire-default.conf /etc/alsa/conf.d/
Everything was already done by the pipewire-pulse
package.
Remove this package and Bluetooth will be handled by PipeWire:
$ sudo apt remove pulseaudio-module-bluetooth
Reboot and check if it works by running:
$ LANG=C pactl info | grep '^Server Name'