I am trying to connect a bluetooth headset to my RPI. My setup is the following:
- archlinux-arm, kernel: linux-raspberrypi 3.12.23-1
- bluez4 4.101-4 from AUR, built and installed
- bluez-tools 0.1.38-3
- bluez-utils 5.20-1
- pulseaudio 5.0-1
- pulseaudio-alsa 2-3
I scan for the device, successfully pair it, add as trusted and connect it:
hcitool scan
bluez-simple-agent hci0 <MAC>
bt-device --set <MAC> Trusted 1
bt-audio -c <MAC>
After this, the device state is as follows (bt-device -i <MAC>
output):
[00:23:7F:2A:3B:24]
Name: PLT 510
Alias: PLT 510 [rw]
Address: 00:23:7F:2A:3B:24
Icon: audio-card
Class: 0x200404
Paired: 1
Trusted: 1 [rw]
Blocked: 0 [rw]
Connected: 1
UUIDs: [Headset, Handsfree]
So, everything seems to be great, right? Well, not quite.
The issue is when I try to play audio, because it seems PulseAudio didn't recognize it and didn't register source
and sink
entries:
[root@alarmpi bluetooth]# pactl list sources short
0 alsa_output.platform-bcm2835_AUD0.0.analog-stereo.monitor module-alsa-card.c s16le 2ch 44100Hz IDLE
[root@alarmpi bluetooth]# pactl list sinks short
0 alsa_output.platform-bcm2835_AUD0.0.analog-stereo module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
I have checked that the module-bluetooth-policy
and module-bluetooth-discover
modules are loaded. Even tried to unload and load back again:
pactl unload-module module-bluetooth-discover
pactl load-module module-bluetooth-discover
Successfully loaded module, but still not showing in the sources
nor sinks
list.
I also tried to configure the /etc/bluetooth/audio.conf
to enable different options like:
Enable=Source,Sink,Media,Socket
Enable=Source,Sink,Headset,Gateway,Control,Media,Socket
Enable=Source,Sink,Media
...
but it didn't change anything.
I am all out of ideas... Why is it not recognized by PulseAudio? Is there something I missed? Do I need to configureI PulseAudio some special way?
I have managed to resolve this issue in the meantime, and here are the steps that worked for me.
The OS in question is archlinux-arm.
Installation
Install the following packages:
- bluez4-4.101-4
- bluez-tools-0.1.38-3
- bluez-utils 5.21-2
- libpulse-4.0-6
- pulseaudio-4.0-6
- pulseaudio-alsa-2-2
- alsa-utils
Note:
I have managed to get PulseAudio to detect my Bluetooth headset using the specific package versions listed here. Some other versions worked also, but most combinations I tried had issues that I couldn't resolve.
Most packages can be built and installed from AUR (bluez4, bluez-tools, ...), and others can be installed easily withpacman
.
Additional preparation
After we installed these package versions, we don't want pacman
to update them later when we do system upgrade. To prevent this, we add the following line to our /etc/pacman.conf
:
IgnorePkg = libpulse pulseaudio pulseaudio-alsa bluez bluez-tools
There are issues with PulseAudio failing to work with bluez4
, especially failing to switch to A2DP
profile when using bluez4
version 4.1 and higher and pulseaudio
version 3.0 or higher. This can be resolved by ommiting the Socket
parameter from the enabled list in the /etc/bluetooth/audio.conf
:
# Enable=Headset,Sink,Source,Socket
Enable=Headset,Sink,Source
If this is not enough, try adding an additional line:
Disable=Socket
Running
It is time to enable and start the bluetooth
service:
systemctl enable bluetooth
systemctl start bluetooth
We can discover our device via hcitool
, bt-adapter
or bt-device
, and connect to it. For example, using the latter:
bt-device -d
bt-device -c <MAC>
bt-device --set <MAC> Trusted 1
bt-audio -c <MAC>
The first command discovers the device, the seconds connects to it by its MAC address. The third one sets it as trusted so we can autoconnect to it later on, when in range. The last command connects it as an audio device. After this, it should be available in pulseaudio
.
Using with PulseAudio
Start the PA via pulseaudio --start
.
Check if the sources and sinks are recognized properly:
pactl list sources short
pactl list sinks short
You should see your BT sink and source listed, which means PA has detected them. Notice the ID values next to the sinks and sources. Use them to set your BT as the default sink/source:
pacmd set-default-source <BT_SOURCE_ID>
pacmd set-default-sink <BT_SINK_ID>
You can find out the BT card id and its supported profiles with pacmd list-cards
. You will probably see at least A2DP
and HSP
profiles listed there. You can switch between them like this:
# pacmd set-card-profile <card_id> <profile_name>
pacmd set-card-profile 1 a2dp
pacmd set-card-profile 1 hsp
Autoconnection
The package bluez-tools contains the tool called bt-monitor that captures the D-Bus signals from the bluetoothd
daemon and initiates the connection for detected devices that are paired (and trusted). Run the bt-monitor
and test by turning off and on your BT headset.
Old question, but I bumped into this while searching for a solution to the above myself, so I thought I'd come here and post how I sorted it out in my setup.
It turns out that Pulseaudio is really not packaged or configured to be run as system daemon, and the default configuration assumes that you will be running within a session, ideally under X. This has direct implications for access to the system bus: Pulseaudio expects a session DBus to be at its disposal, and module-bluetooth-discover relies on this in order to dynamically load module-buetooth-device and set up the corresponding sinks/sources.
SO, you need to add an exception to DBus rules. This guide here recommends adding the following to /etc/dbus-1/system.d/pulse.conf:
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy user="root">
<allow own="org.pulseaudio.Server"/>
<allow send_destination="org.bluez"/>
<allow send_interface="org.bluez.Manager"/>
</policy>
<policy user="pulse">
<allow own="org.pulseaudio.Server"/>
<allow send_destination="org.bluez"/>
<allow send_interface="org.bluez.Manager"/>
</policy>
<policy context="default">
<deny own="org.pulseaudio.Server"/>
<deny send_destination="org.bluez"/>
<deny send_interface="org.bluez.Manager"/>
</policy>
</busconfig>
But in my case (Raspbian Wheezy) this file was not empty, so YMMV. Do note that the last part (context default, all deny) is critical, and PA will not get notifications from Dbus if is is missing.
Add the rules, then:
service dbus restart
service bluetooth restart
service pulseaudio restart
and pactl should list a bluez source when a device connects. Good luck!
ps: I'm sorry that I don't have an exact solution for arch, but I'm pretty sure the above applies (the original guide was written for fedora...)
来源:https://stackoverflow.com/questions/24580155/pulseaudio-not-detecting-bluetooth-headset