Debian Bookworm and Bluetooth audio

How to listen music on bluetooth device under Debian Bookworm distro, the reality at 2021-11-12.

I thought myself that it would be good to write an article regarding bluetooth audio in Debian Bookwork distro. I like to have up to date Linux Debian distro on my computer so I upgraded from Bullseye to Bookworm by command apt dist-upgrade after earlier updating /etc/apt/sources.list file.
In Bullseye distro Bluetooth audio is supported by Pulseaudio but in Bookworm we use Bluealsa however after connecting to Hi-Fi Amplifier in Blueman-applet I could not force programs like Firefox to play music on it and more over in "Sound Preferences" I did not see additional sound card so I cannot even control audio volume so here is my way on workaround this problem:
  • pair Bluetooth audio in Blueman-applet;
  • login as root on console: su - and give root password;
  • install alsa utils apt install bluez-alsa-utils alsa-utils;
  • load Linux audio loop interface modprobe snd-aloop which will create additional audio card in the system;
  • now we need to redirect audio from loop interface to bluealsa by following command alsaloop -C hw:1,1,0 -P bluealsa:00:1A:80:EB:45:D7 where 00:1A:80:EB:45:D7 is the mac address taken from Blueman-applet application. alsaloop application will be printing output on console which we need to minimize and leave running.

After theese operations we can change default destination sound card in "Sound Preferences" and we can play audio over Bluetooth in Firefox