Pulseaudio not detecting bluetooth headset [closed]

无人久伴 提交于 2019-12-05 15:06:12

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

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!