PulseAudio fails to set card profile to 'a2dp_sink'. How can I see the logs and figure out whats wrong?

I have currently installed ubuntu 16.04 and a2dp used to work on fresh install, which I'd prefer to leave as a last option. When the pairing is erased from bluetooth settings and is paired again sometimes it manages to be on a2dp profile, but if the headset is disconnected and then reconnected the a2dp profiles doesn't work anymore (though it says is on a2dp), it only works after switching to HSP/HSF and then I'm unable to set it on a2dp.

I have tried doing:

 pacmd set-card-profile <index> a2dp_sink

but the following error comes out:

"Failed to set card profile to 'a2dp_sink'"

I'm quite inexperienced in Linux so I don't know how to get logs or what to look for in them, but I got this from pacmd list-cards:

When it works:

name: <bluez_card.50_C9_71_97_A1_86>
driver: <module-bluez5-device.c>
owner module: 27
properties:
    device.description = "Jabra REVO a4.0.0"
    device.string = "50:C9:71:97:A1:86"
    device.api = "bluez"
    device.class = "sound"
    device.bus = "bluetooth"
    device.form_factor = "headset"
    bluez.path = "/org/bluez/hci0/dev_50_C9_71_97_A1_86"
    bluez.class = "0x240404"
    bluez.alias = "Jabra REVO a4.0.0"
    device.icon_name = "audio-headset-bluetooth"
    device.intended_roles = "phone"
profiles:
    headset_head_unit: Headset Head Unit (HSP/HFP) (priority 20, available: unknown)
    a2dp_sink: High Fidelity Playback (A2DP Sink) (priority 10, available: unknown)
    off: Off (priority 0, available: yes)
active profile: <a2dp_sink>
sinks:
    bluez_sink.50_C9_71_97_A1_86/#6: Jabra REVO a4.0.0
sources:
    bluez_sink.50_C9_71_97_A1_86.monitor/#10: Monitor of Jabra REVO a4.0.0
ports:
    headset-output: Headset (priority 0, latency offset 0 usec, available: unknown)
        properties:

    headset-input: Headset (priority 0, latency offset 0 usec, available: unknown)
        properties:

When it doesn't:

name: <bluez_card.50_C9_71_97_A1_86>
driver: <module-bluez5-device.c>
owner module: 25
properties:
    device.description = "Jabra REVO a4.0.0"
    device.string = "50:C9:71:97:A1:86"
    device.api = "bluez"
    device.class = "sound"
    device.bus = "bluetooth"
    device.form_factor = "headset"
    bluez.path = "/org/bluez/hci0/dev_50_C9_71_97_A1_86"
    bluez.class = "0x240404"
    bluez.alias = "Jabra REVO a4.0.0"
    device.icon_name = "audio-headset-bluetooth"
    device.intended_roles = "phone"
profiles:
    headset_head_unit: Headset Head Unit (HSP/HFP) (priority 20, available: unknown)
    a2dp_sink: High Fidelity Playback (A2DP Sink) (priority 10, available: yes)
    off: Off (priority 0, available: yes)
active profile: <off>
ports:
    headset-output: Headset (priority 0, latency offset 0 usec, available: yes)
        properties:

    headset-input: Headset (priority 0, latency offset 0 usec, available: unknown)
        properties:

And the owning module is:

name: <module-bluez5-device>
argument: <path=/org/bluez/hci0/dev_50_C9_71_97_A1_86>
used: 0
load once: no
properties:
    module.author = "João Paulo Rechi Vita"
    module.description = "BlueZ 5 Bluetooth audio sink and source"
    module.version = "8.0"

I have already tried to modify /etc/bluetooth/audio.conf and install blueman but it didn't work. I also tried to reinstall bluez and pulseaudio but nothing changed.

Is there any way I can know what's wrong and fix it?


In order to allow your system to be detected as an A2DP sink (e.g. to play music from your phone via your computer speakers), add Enable=Source,Sink,Media,Socket under [General] in /etc/bluetooth/audio.conf.

After doing this, restart the bluetooth daemon

systemctl restart bluetooth

Connect you headphone device

bluetoothctl
connect <MAC>

Check your card and set profile

pactl list cards short
pacmd set-card-profile <index> <profile>

Based on the line "active profile: <off>" the sound profile didn't activate.

One program that is easy to use to change the profile is pavucontrol. You can install it with sudo apt install pavucontrol -y. Then run pavucontrol from the command line or Alt+F2 if you are on Kubuntu and entering pavucontrol.

Select the configuration tab and then try changing the profile for your headphones and see if that updates for you. There seem to be a bug with bluetooth a2dp still in linux and it affects two of my 16.04 installations. If it already says A2DP change it to OFF, disconnect the device in the bluetooth applet, then reconnect it. Then finally proceed to change the profile back to A2DP and it should work.

You can also try the following on the command line and it should tab complete most of it for you. Replace the number 2 with the index number currently for both pacmd commands below.

pacmd set-card-profile 2 off
bluetoothctl
disconnect 50:C9:71:97:A1:86
connect 50:C9:71:97:A1:86
pacmd set-card-profile 2 a2dp_sink

For a more complicated but automated way of doing the same thing for cycling the profile to off and then back to a2dp but not do the bluetooth device disconnect and connect

index=`pacmd list-cards | grep bluez_card -B1 | grep index | awk '{print $2}'`;pacmd set-card-profile $index off; pacmd set-card-profile $index a2dp_sink 

I was also to make a working but sloppy script to do the same thing but also disconnect and reconnect the bluetooth headphones. It grabs the profile index because the index changes every time the device is disconnected and reconnected. This is hardcoded with the device id for the headset you listed above

pacmd set-card-profile `pacmd list-cards | grep bluez_card -B1 | grep index | awk '{print $2}'` off; sleep 2 ; echo -e "disconnect 50:C9:71:97:A1:86\n quit"|bluetoothctl;sleep 5; echo -e "connect 50:C9:71:97:A1:86\n quit"|bluetoothctl; sleep 5; pacmd set-card-profile `pacmd list-cards | grep bluez_card -B1 | grep index | awk '{print $2}'` a2dp_sink

During testing I ended up with the 5 seconds for sleep instead of 3 because the device wasn't ready to change the audio profile yet. Your results may vary by a few seconds +/- 5 seconds. Edit regarding a potential pitfall. I did find that it's is occasionally needed to run the larger script twice before it works. I'm not sure if increasing the sleep times would help or not as I haven't tested that. But I have used it on two machines with the same brand of BT headphones and it's doing what it's supposed to for automating the process to get the sound working on the headphones.

Eventually the issue will be patched in the bluetooth package but seems to keep returning in new releases of Ubuntu as well as other versions of Linux. But anyhow hope that helps for you


I had this problem on Ubuntu 16.04.1 LTS, and applying the GDM work around found in https://wiki.debian.org/BluetoothUser/a2dp solved it.

Specifically, create/edit /var/lib/gdm3/.config/pulse/client.conf to read:

autospawn = no
daemon-binary = /bin/true

Then

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

I also added to /etc/pulse/default.pa

load-module module-switch-on-connect

Though this might not be strictly necessary.

After a reboot, I connected via bluetooth manager was able to successfully switch the audio profile to a2dp_sink.


lagerismi posted a script here on launchpad based on the answer by Jamie S.

  • Change the devices MAC-address in the variable inside the script! (can be found with bluetoothctl --> Device)

  • Make the script executable chmod a-x bluetooth_headphone_reactivation.sh

For automatic execution at startup (only works if headset is already turned on):

  • Add the script to the start/shutdown scripts in KDE's control panel

For fast manual execution:

  • Add an entry to the application-starter (you can also set a keyboad shortcut like "CTRL+ALT+H" and/or pin this starter to the window bar)

The script:

#!/bin/sh  
device_mac='<your-devices-mac-address-here>' # From bluetoothctl info
pacmd set-card-profile "$(pacmd list-cards | grep bluez_card -B1 | grep index | awk '{print $2}')" off
sleep 2
echo "disconnect $device_mac\n quit" | bluetoothctl
sleep 5
echo "connect $device_mac\n quit" | bluetoothctl
sleep 5
pacmd set-card-profile "$(pacmd list-cards | grep bluez_card -B1 | grep index | awk '{print $2}')" a2dp_sink

On Xubuntu 16.04.2
Use blueman-manager:

  1. connect -> set profile off
  2. reconnect -> set profile a2dp
  3. now your headset is ok!

My JBL bash script

#!/bin/bash
#headset mac
mac="00:1D:DF:67:0A:29"
profile="a2dp"
# Special Bluetooth controller, default is empty
btMac=""
#connect|disconnect wait time
waitTime=5

macId="${mac//:/_}"
deviceId="bluez_card.$macId"

declare -A profiles
profiles['a2dp']='a2dp_sink'
profiles['hsp']='headset_head_unit'
profiles['off']='off'

function btCmd() {
    cmd="$1\nquit"
    [ ! -z "$btMac" ] && cmd="select $btMac\n$cmd"
    echo -e "$cmd" | bluetoothctl
}
function setProfile() {
    cmd="pactl set-card-profile $deviceId ${profiles[$1]}"
    echo $cmd
    $cmd
}
function btWaitConnect() {
    conState=$1
    for ((i=1;i<=$waitTime;++i)); do
        tmp="`btCmd "info $mac"|grep 'Connected: '`"
        [ ! -z "`echo "$tmp"|grep $conState`" ] && echo "$tmp" && return 0
        sleep 1s
    done
    echo "$tmp"
    return 1
}
function btConnect() {
    tmp="`btCmd "trust $mac\nconnect $mac" | grep -v 'NEW\|DEL\| quit'`"
    echo "$tmp"

    tmp="`btWaitConnect yes`"
    echo $tmp
    [ -z "`echo "$tmp" | grep yes`" ] && echo -e "Device $mac:\n\tConnected: fail." && return 1
    sleep 2s
    return 0
}
function btDisConnect() {
    tmp="`btCmd "disconnect $mac" | grep -v 'NEW\|DEL\| quit'`"
    echo "$tmp"

    tmp="`btWaitConnect no`"
    echo $tmp
    [ -z "`echo "$tmp" | grep no`" ] && echo -e "Device $mac:\n\tdisconnected: fail." && return 1
    sleep 1s
    return 0    
}


# controller
echo ""
btCtls="`btCmd list | grep '^Controller' | grep " $btMac"`"
echo -e "controller:\n$btCtls"
[ -z "$btCtls" -o ! -z "`echo "$btCtls" | grep "not available"`" ] && exit 1


# connect -> set off
echo ""
tmp="`btCmd paired-devices | grep '^Device' | grep " $mac"`"
echo -e "paired-devices:\n$tmp"
[ `echo "$tmp" | wc -l` != 1 ] && echo "Please pair the Bluetooth headset first: $mac" && exit 1
btConnect || exit $?
setProfile off

# reconnect -> set profile
btDisConnect || exit $?
btConnect || exit $?
setProfile $profile