bluetoothraspberry-pibluezpulseaudioarchlinux-arm

Pulseaudio not detecting bluetooth headset


I am trying to connect a bluetooth headset to my RPI. My setup is the following:

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?


Solution

  • 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:

    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.