Differences between revisions 23 and 34 (spanning 11 versions)
Revision 23 as of 2019-10-04 22:51:02
Size: 5665
Editor: TheAnarcat
Comment: weird problem with "protocol not available"
Revision 34 as of 2021-11-06 20:24:23
Size: 9586
Comment: Add a warning to the PipeWire section after I received an email mentioning that gnome-core depends on pulseaudio-module-bluetooth. Also remove DebianExperimental reference now that it's in testing.
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
A2DP is the "Advanced Audio Distribution Profile" which describes how Bluetooth devices can stream stereo-quality audio to remote devices. It enables connecting high quality audio bluetooth devices, such as headphones and speakers, to your system. #language en
~-[[DebianWiki/EditorGuide#translation|Translation(s)]]: none-~
----
A2DP is the "Advanced Audio Distribution Profile", a standard for how Bluetooth devices can stream high-quality audio to remote devices. This is most commonly used for linking wireless headphones and speakers to your PC. The instructions in this page should apply to any A2DP-compatible device.
Line 5: Line 8:
== Requirements == == Pre-configuration ==
Line 7: Line 10:
To connect to a given device you need working bluetooth on your machine and the following packages, one of which is non-free software which will require you to enable the non-free repository in your /etc/apt/source.list file. In short: To connect to a given device, you need Bluetooth hardware on your PC (either built-in, or in the form of a USB dongle), the Bluez daemon, and a compatible audio server (either PulseAudio or PipeWire).

=== Firmware ===
If your hardware supports Bluetooth but Debian is unable to find any Bluetooth devices, you may have a dongle based on a Broadcom BCM203x chipset, requiring extra firmware to be installed.

Add a non-free component to your [[SourcesList|apt sources]] and install the DebianPkg:bluez-firmware package.

=== PulseAudio ===
PulseAudio is the default audio server in Debian. Unless you know what you're doing, you probably want to follow these instructions.

Install the DebianPkg:pulseaudio-module-bluetooth package if it's not already installed. You probably also want DebianPkg:pavucontrol (or DebianPkg:pavucontrol-qt on LXQt or Plasma desktops) to configure your device after connecting it.

Once you have installed the Bluetooth module, it may be necessary to restart the bluetooth and pulseaudio services:
Line 10: Line 25:
apt-get install pulseaudio pulseaudio-module-bluetooth pavucontrol bluez-firmware # service bluetooth restart
$ killall pulseaudio
Line 13: Line 29:
Once you have installed these packages, it may be necessary to restart the bluetooth and pulseaudio services: After connecting your device (see the "Pairing" section), your device will appear in Pavucontrol, where you can set it as your default audio output device, change individual applications to output using it, configure its profile, etc.
Line 15: Line 31:
{{{
service bluetooth restart
}}}
=== PipeWire ===
These instructions are mutually exclusive to the !PulseAudio section, for users
that are using the newer PipeWire audio server instead. This is also documented on
the !PipeWire wiki page in brief. Note that simply having the DebianPkg:pipewire
package installed does not mean this section is relevant to you, as it needs to
have also been specially configured to replace !PulseAudio.
Line 19: Line 38:
{{{
killall pulseaudio
}}}
In Debian, !PipeWire supports more modern codecs than !PulseAudio without the need to install any external modules. In particular, !PipeWire 0.3.26 supports mSBC, SBC, SBC-XQ, LDAC, AptX, and AptX-HD. It also supports the HSP_HS, HSP_AG, HFP_HF, and HFP_AG headset roles. Support for more codecs is in-progress.

At minimum, you will need to install the [[DebianPkg:libspa-0.2-bluetooth]] package, remove the DebianPkg:pulseaudio-module-bluetooth package (if previously installed), and then either reboot your computer or restart the !PipeWire services, otherwise device connections will fail with "Protocol not available".

Note that, if you're using the GNOME desktop, the DebianPkg:gnome-core package
has a hard dependency on pulseaudio-module-bluetooth. Attempting to
remove it will also prompt to remove your desktop. If you run into issues when
attempting to use Bluetooth with this package installed, you may still have to
use !PulseAudio in order to have functioning Bluetooth audio.

!PipeWire will attempt to choose the best possible codec by default. You can override this, and tweak many other related settings, in the {{{/etc/pipewire/media-session.d/bluez-monitor.conf}}} file. You can edit this directly, or store local per-user changes by copying the file to {{{~/.config/pipewire/media-session.d/bluez-monitor.conf}}} and editing that instead. You can check the currently-used codec with {{{pactl list sinks}}}

=== ALSA only ===
If you want to completely avoid using a higher-level audio server like !PipeWire or !PulseAudio, see [[Bluetooth/Alsa|BlueALSA]]. Currently only available in Debian Unstable.

----
Line 25: Line 57:
It is also highly recommended to install a graphical pairing tool. If you are using GNOME as your desktop environment, '''bluetooth-applet''' should already be installed from the [[DebianPkg:gnome-bluetooth|gnome-bluetooth]] package. It is also highly recommended to install a graphical pairing tool. GNOME relies on DebianPkg:gnome-bluetooth, after which you can find a "Bluetooth" section of your settings. KDE Plasma relies on DebianPkg:bluedevil, which is a module for your system settings, a system tray applet, and a wizard for connecting to your devices. Other desktops can use the agnostic DebianPkg:blueman tool.
Line 27: Line 59:
If you are using an alternative desktop environment that does not already include graphical bluetooth tools, you can use the '''blueman-applet''' from the [[DebianPkg:blueman|blueman]] package: More information, and instructions on using the CLI {{{bluetoothctl}}} tool, can be found on the main BluetoothUser page.
Line 29: Line 61:
{{{
apt-get install blueman
}}}

Both of these applets will appear in the notification area of your desktop environment and will provide options for pairing and connecting to your speakers or headphones.

Pair your device as usual and give it the "trust" attribute. The "trust" attribute allows the device to automatically establish a connection to your machine when turned on and in range.

== Configuring ==

Using '''pavucontrol''' from the [[DebianPkg:pavucontrol|pavucontrol]] package, it is really easy to setup A2DP for your device, and map connections to it. Your paired headphones should appear as an option to output audio.

Don't forget to put it in high quality mode (A2DP) in the configuration tab. This is necessary for some devices that have mixed mode.

== Compatible devices ==

Any A2DP device should work out of the box.

If you still didn't bought one, the Creative WP-300 works very well and has a very very nice sound.
----
Line 53: Line 67:
Bluetooth headset is connected, but ALSA/PulseAudio fails to pick up the connected device or there's no device to pick. This happens because GDM captures A2DP sink on session start, as GDM needs pulseaudio in the gdm session for accessibility. For example, the screen
reader requires it. See [[DebianBug:805414]] for some discussion.
Your Bluetooth headset is connected, but PulseAudio fails to pick up the connected device, or there's no device to pick. This happens because GDM captures A2DP sink on session start, as GDM needs !PulseAudio in the GDM session for accessibility. For example, the screen reader requires it. See [[DebianBug:805414]] for some discussion.
Line 56: Line 69:
==== Workaround 1: disable pulseaudio in gdm ==== ==== Workaround 1: Disable PulseAudio in GDM ====
Line 71: Line 84:
You will also need to disable pulseaudio startup: You may also need to disable !PulseAudio startup (however in Debian 10/Buster and newer, this has already been removed in the gdm3 postinst):
Line 77: Line 90:
In order to auto-connect a2dp for some devices, add this to '''/etc/pulse/default.pa''': In order to auto-connect A2DP for some devices, add this to '''/etc/pulse/default.pa''':
Line 85: Line 98:
Now the sound device (bluetooth headset) should be accessible through '''pavucontrol''' and standard audio device manager. Now your audio device should be accessible through '''pavucontrol''' and your desktop's standard audio settings.
Line 87: Line 100:
==== Workaround 2: disable pulseaudio's bluetooth in gdm ==== ==== Workaround 2: Disable PulseAudio's Bluetooth in GDM ====
Line 89: Line 102:
The actual solution package maintainers are looking into next is to simply disable the bluetooth sink in the gdm pulseaudio daemon so that it doesn't take over the device. Add this to `/var/lib/gdm3/.config/pulse/default.pa`: The actual solution package maintainers are looking into next is to simply disable the Bluetooth sink in the GDM !PulseAudio daemon so that it doesn't take over the device. Add this to `/var/lib/gdm3/.config/pulse/default.pa`:
Line 113: Line 126:
The actual solution is for pulseaudio to release the Bluetooth device when it is not in use. This is discussed in the Pulseaudio DebianBug:845938 which has a few upstream bugs pending as well that are related. The actual solution is for !PulseAudio to release the Bluetooth device when it is not in use. This is discussed in the !PulseAudio DebianBug:845938 which has a few upstream bugs pending as well that are related.
Line 117: Line 130:
The volumeicon tray icon may not automatically recognize a bluetooth a2dp device when a connection is established. See [[https://github.com/Maato/volumeicon/issues/73|Volumeicon does not work to adjust bluetooth volume]] for discussion and possible workarounds / fix. The volumeicon tray icon may not automatically recognize a Bluetooth A2DP device when a connection is established. See [[https://github.com/Maato/volumeicon/issues/73|issue #73, "volumeicon does not work to adjust bluetooth volume"]] and [[https://github.com/Maato/volumeicon/issues/49|issue #49, "change of the default device not automatically detected"]] for discussion and possible workarounds / fix. You might also try simply restarting Volumeicon, or adjusting your !PulseAudio configuration to switch on connect.
Line 119: Line 132:
==== Workaround 1: restart volumeicon ==== === a2dp-sink profile connect failed [...]: Protocol not available ===
Line 121: Line 134:
==== Workaround 2: adjust pulseaudio configuration to switch on connect ====
[[https://github.com/Maato/volumeicon/issues/49|Change of the default device not automatically detected]]
This error can appear when using !PipeWire as your audio server and attempting to pair a device via Bluetooth, without first uninstalling the DebianPkg:pulseaudio-module-bluetooth package.
Line 124: Line 136:
=== a2dp-sink profile connect failed [...]: Protocol not available
Line 126: Line 137:
I have had problems connecting with a bluetooth speaker once, with this error in the logs: If you're using !PulseAudio, !PulseAudio may not be properly connecting to the device. It might be because it was already playing. Stopping anything playing on !PulseAudio, restarting !PulseAudio, and reconnecting to the device may fix the problem.

In addition, you need the following settings in /etc/pulse/default.pa or /etc/pulse/default.pa.d/bluez5.pa:
Line 129: Line 142:
oct 04 18:46:19 angela bluetoothd[8025]: a2dp-sink profile connect failed for XX:XX:XX:XX:XX: Protocol not available load-module module-bluez5-device
load-module module-bluez5-discover
Line 132: Line 146:
I am not sure exactly what the problem is, but it seems like Pulseaudio wasn't properly connecting to the device. It might be because it was already playing. Stopping anything playing on pulseaudio, restarting pulseaudio and reconnecting to the device fixed the problem. Then restart pulseaudio.

=== AptX, LDAC, and AAC codecs are not available with PulseAudio ===

While newer audio codecs such as AptX and LDAC are available in PipeWire, they're still unavailable for !PulseAudio users in Debian. AAC is unavailable outright because the library is non-free. However, !PulseAudio has recently gained support for all of these codecs via GStreamer. Unfortunately, GStreamer is only supporting these codecs from v1.20 onwards. This means that support for modern codecs with !PulseAudio is not available in Debian 10 or Debian 11. It is expected to land in Debian 12.

A third-party project adds support for these additional codecs as well. It is deprecated and the creator recommends users either avoid it entirely, or switch to !PipeWire. Nonetheless, it's still a fully functional option in Debian 10: https://github.com/EHfive/pulseaudio-modules-bt

Additionally, a third-party script for Debian 10 is available which will automatically configure and install the additional codecs via the deprecated pulseaudio-modules-bt project: https://github.com/lagerimsi-ds/debian-buster_bluetooth_aptX-LDAC

If the !PulseAudio sink adjusts automatically to SBC-sink (not A2DP-sink with aptX or LDAC), just reconnect your device.

----

== See also ==
 * [[BluetoothUser]] - Main page for Bluetooth in Debian
 * [[bluedevil|BlueDevil]] - Bluetooth with KDE Plasma
 * [[Bluetooth/Alsa|BlueALSA]] - Bluetooth over ALSA alone

----

CategorySound CategoryWireless

Translation(s): none


A2DP is the "Advanced Audio Distribution Profile", a standard for how Bluetooth devices can stream high-quality audio to remote devices. This is most commonly used for linking wireless headphones and speakers to your PC. The instructions in this page should apply to any A2DP-compatible device.

Pre-configuration

In short: To connect to a given device, you need Bluetooth hardware on your PC (either built-in, or in the form of a USB dongle), the Bluez daemon, and a compatible audio server (either PulseAudio or PipeWire).

Firmware

If your hardware supports Bluetooth but Debian is unable to find any Bluetooth devices, you may have a dongle based on a Broadcom BCM203x chipset, requiring extra firmware to be installed.

Add a non-free component to your apt sources and install the bluez-firmware package.

PulseAudio

PulseAudio is the default audio server in Debian. Unless you know what you're doing, you probably want to follow these instructions.

Install the pulseaudio-module-bluetooth package if it's not already installed. You probably also want pavucontrol (or pavucontrol-qt on LXQt or Plasma desktops) to configure your device after connecting it.

Once you have installed the Bluetooth module, it may be necessary to restart the bluetooth and pulseaudio services:

# service bluetooth restart
$ killall pulseaudio

After connecting your device (see the "Pairing" section), your device will appear in Pavucontrol, where you can set it as your default audio output device, change individual applications to output using it, configure its profile, etc.

PipeWire

These instructions are mutually exclusive to the PulseAudio section, for users that are using the newer PipeWire audio server instead. This is also documented on the PipeWire wiki page in brief. Note that simply having the pipewire package installed does not mean this section is relevant to you, as it needs to have also been specially configured to replace PulseAudio.

In Debian, PipeWire supports more modern codecs than PulseAudio without the need to install any external modules. In particular, PipeWire 0.3.26 supports mSBC, SBC, SBC-XQ, LDAC, AptX, and AptX-HD. It also supports the HSP_HS, HSP_AG, HFP_HF, and HFP_AG headset roles. Support for more codecs is in-progress.

At minimum, you will need to install the libspa-0.2-bluetooth package, remove the pulseaudio-module-bluetooth package (if previously installed), and then either reboot your computer or restart the PipeWire services, otherwise device connections will fail with "Protocol not available".

Note that, if you're using the GNOME desktop, the gnome-core package has a hard dependency on pulseaudio-module-bluetooth. Attempting to remove it will also prompt to remove your desktop. If you run into issues when attempting to use Bluetooth with this package installed, you may still have to use PulseAudio in order to have functioning Bluetooth audio.

PipeWire will attempt to choose the best possible codec by default. You can override this, and tweak many other related settings, in the /etc/pipewire/media-session.d/bluez-monitor.conf file. You can edit this directly, or store local per-user changes by copying the file to ~/.config/pipewire/media-session.d/bluez-monitor.conf and editing that instead. You can check the currently-used codec with pactl list sinks

ALSA only

If you want to completely avoid using a higher-level audio server like PipeWire or PulseAudio, see BlueALSA. Currently only available in Debian Unstable.


Pairing

It is also highly recommended to install a graphical pairing tool. GNOME relies on gnome-bluetooth, after which you can find a "Bluetooth" section of your settings. KDE Plasma relies on bluedevil, which is a module for your system settings, a system tray applet, and a wizard for connecting to your devices. Other desktops can use the agnostic blueman tool.

More information, and instructions on using the CLI bluetoothctl tool, can be found on the main BluetoothUser page.


Troubleshooting

Refused to switch profile to a2dp_sink: Not connected

Your Bluetooth headset is connected, but PulseAudio fails to pick up the connected device, or there's no device to pick. This happens because GDM captures A2DP sink on session start, as GDM needs PulseAudio in the GDM session for accessibility. For example, the screen reader requires it. See 805414 for some discussion.

Workaround 1: Disable PulseAudio in GDM

In order to prevent GDM from capturing the A2DP sink on session start, edit /var/lib/gdm3/.config/pulse/client.conf (or create it, if it doesn't exist):

autospawn = no
daemon-binary = /bin/true

After that you have to grant access to this file to Debian-gdm user:

chown Debian-gdm:Debian-gdm /var/lib/gdm3/.config/pulse/client.conf

You may also need to disable PulseAudio startup (however in Debian 10/Buster and newer, this has already been removed in the gdm3 postinst):

rm /var/lib/gdm3/.config/systemd/user/sockets.target.wants/pulseaudio.socket

In order to auto-connect A2DP for some devices, add this to /etc/pulse/default.pa:

load-module module-switch-on-connect

Reboot.

Now your audio device should be accessible through pavucontrol and your desktop's standard audio settings.

Workaround 2: Disable PulseAudio's Bluetooth in GDM

The actual solution package maintainers are looking into next is to simply disable the Bluetooth sink in the GDM PulseAudio daemon so that it doesn't take over the device. Add this to /var/lib/gdm3/.config/pulse/default.pa:

#!/usr/bin/pulseaudio -nF
#

# load system wide configuration
.include /etc/pulse/default.pa

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

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

This was first discovered in the Arch wiki.

Solution

The actual solution is for PulseAudio to release the Bluetooth device when it is not in use. This is discussed in the PulseAudio 845938 which has a few upstream bugs pending as well that are related.

Unable to control volume with volumeicon-alsa

The volumeicon tray icon may not automatically recognize a Bluetooth A2DP device when a connection is established. See issue #73, "volumeicon does not work to adjust bluetooth volume" and issue #49, "change of the default device not automatically detected" for discussion and possible workarounds / fix. You might also try simply restarting Volumeicon, or adjusting your PulseAudio configuration to switch on connect.

a2dp-sink profile connect failed [...]: Protocol not available

This error can appear when using PipeWire as your audio server and attempting to pair a device via Bluetooth, without first uninstalling the pulseaudio-module-bluetooth package.

If you're using PulseAudio, PulseAudio may not be properly connecting to the device. It might be because it was already playing. Stopping anything playing on PulseAudio, restarting PulseAudio, and reconnecting to the device may fix the problem.

In addition, you need the following settings in /etc/pulse/default.pa or /etc/pulse/default.pa.d/bluez5.pa:

load-module module-bluez5-device
load-module module-bluez5-discover

Then restart pulseaudio.

AptX, LDAC, and AAC codecs are not available with PulseAudio

While newer audio codecs such as AptX and LDAC are available in PipeWire, they're still unavailable for PulseAudio users in Debian. AAC is unavailable outright because the library is non-free. However, PulseAudio has recently gained support for all of these codecs via GStreamer. Unfortunately, GStreamer is only supporting these codecs from v1.20 onwards. This means that support for modern codecs with PulseAudio is not available in Debian 10 or Debian 11. It is expected to land in Debian 12.

A third-party project adds support for these additional codecs as well. It is deprecated and the creator recommends users either avoid it entirely, or switch to PipeWire. Nonetheless, it's still a fully functional option in Debian 10: https://github.com/EHfive/pulseaudio-modules-bt

Additionally, a third-party script for Debian 10 is available which will automatically configure and install the additional codecs via the deprecated pulseaudio-modules-bt project: https://github.com/lagerimsi-ds/debian-buster_bluetooth_aptX-LDAC

If the PulseAudio sink adjusts automatically to SBC-sink (not A2DP-sink with aptX or LDAC), just reconnect your device.


See also


CategorySound CategoryWireless