Differences between revisions 1 and 19 (spanning 18 versions)
Revision 1 as of 2013-06-03 11:32:42
Size: 1327
Editor: ?JavierRodriguez
Comment:
Revision 19 as of 2017-07-03 14:14:48
Size: 4513
Editor: TheAnarcat
Comment: add toc
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
A2DP is the technology that allows connecting high quality audio bluetooth devices to your system. 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.
Line 3: Line 3:
== Packages == <<TableOfContents>>
Line 5: Line 5:
To connect your headphones, you need a working host device, and the following packages: == Requirements ==

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.
Line 8: Line 10:
apt-get install pulseaudio pulseaudio-module-bluetooth bluez-audio pavucontrol bluez-firmware bluez-tools apt-get install pulseaudio pulseaudio-module-bluetooth pavucontrol bluez-firmware
Line 11: Line 13:
It is also highgly recommended to install a graphical pairing tool. '''bluetooth-agent''' is already included with gnome, but you can also use '''blueman'''.

Don't forget to restart bluetooth service:
Once you have installed these packages, it may be necessary to restart the bluetooth and pulseaudio services:
Line 19: Line 19:
{{{
killall pulseaudio
}}}
Line 22: Line 25:
Pair your device as usual and give it the "trust" attribute. 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.

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:

{{{
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.
Line 26: Line 39:
Using '''pavucontrol''', 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. 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.
Line 28: Line 41:
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.

If you prefer to use the command line, just do:

{{{
bt-audio -c 00:02:3C:38:AC:B9
}}}

Where ''00:02:3C:38:AC:B9'' is the address of your paired device.
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.
Line 43: Line 48:

== Troubleshooting ==

=== Refused to switch profile to a2dp_sink: Not connected ===

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.

==== 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 will also need to disable pulseaudio startup:

{{{
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 the sound device (bluetooth headset) should be accessible through '''pavucontrol''' and standard audio device manager.

==== Workaround 2: disable 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 [[https://wiki.archlinux.org/index.php/Talk:Bluetooth_headset#GDMs_pulseaudio_instance_captures_bluetooth_headset|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 DebianBug:845938 which has a few upstream bugs pending as well that are related.

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.

Requirements

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.

apt-get install pulseaudio pulseaudio-module-bluetooth pavucontrol bluez-firmware

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

service bluetooth restart

killall pulseaudio

Pairing

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 gnome-bluetooth package.

If you are using an alternative desktop environment that does not already include graphical bluetooth tools, you can use the blueman-applet from the blueman package:

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 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.

Troubleshooting

Refused to switch profile to a2dp_sink: Not connected

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 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 will also need to disable pulseaudio startup:

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 the sound device (bluetooth headset) should be accessible through pavucontrol and standard audio device manager.

Workaround 2: disable 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:

#

# 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.