43

Since I installed Ubuntu 20.04 I have been facing problems with my Bluetooth headset microphone not detected by the system. My headset worked perfectly with Windows. Also, I am not able to switch to HFP from AD2P in Ubuntu. So my final thought is to remove PulseAudio and install pipewire hoping that it will solve my problems.

Can anyone please provide the steps to do the same? I have searched it quite a few times but have not been able to get to the correct steps.

1nfern0
  • 2,499

7 Answers7

79

I was facing the same issue with Oneplus Wireless Z Bass edition. My headset microphone was not detected by PulseAudio and the problem is that my headphones don't have HSP profile, only HFP profile. After trying for 2 days, I came to the solution of replacing PulseAudio with Pipewire sound server, which supports HSP, HFP and A2DP by itself. So there will be no need to install any other utility like ofono, phonesim. Also, to be noted that my problem wasn't resolved even after following all the steps to configure ofono in PulseAudio. So I came up with the steps to replace PulseAudio with PipeWire.

Here is the detailed article I have written to resolve this problem, the steps of which I'm also adding here. You can follow it and most probably be able to solve your problem.

Bluetooth headset microphone not detected

Open your terminal and follow these steps:

  1. We will use a PPA for adding Pipewire to Ubuntu 20.04, which is maintained regularly:

    sudo add-apt-r-epository ppa:pipewire-debian/pipewire-upstream
    
  2. To update the PPA packages in your system do:

    sudo apt update
    
  3. Install the package:

    sudo apt install pipewire
    
  4. There is also a dependency needed to be installed with Pipewire, otherwise you will face the issue of “Bluetooth headset won’t connect after installing pipewire”. Install the dependency by:

    sudo apt install libspa-0.2-bluetooth
    
  5. Now, to install the client libraries:

    sudo apt install pipewire-audio-client-libraries
    
  6. Reload the daemon:

    systemctl --user daemon-reload
    
  7. Disable PulseAudio:

    systemctl --user --now disable pulseaudio.service pulseaudio.socket
    
  8. If you are on Ubuntu 20.04, you also need to “mask” the PulseAudio by:

    systemctl --user mask pulseaudio
    

    I am not sure but, if possible, you can try to run this on other versions too.

  9. After a new update of Pipewire, you also need to enable pipewire-media-session-service:

    systemctl --user --now enable pipewire-media-session.service
    
  10. You can ensure that Pipewire is now running through:

    pactl info
    

    This command will give the following output, in Server Name you can see:

        PulseAudio (on PipeWire 0.3.28)
    

Things should be working by now and you can see your microphone.

If it doesn’t show up, then try restarting Pipewire by this command:

systemctl --user restart pipewire

You need to uninstall ofono and phonesim from your system if you have them installed.

sudo apt remove ofono
sudo apt remove ofono-phonesim

If it’s still not showing your microphone, you can try rebooting once and remove and pair your Bluetooth device again to check if it works now.

I hope I have helped you solve your problem.

If you want to rollback all the changes we did, you can do it by using:

systemctl --user unmask pulseaudio
systemctl --user --now disable pipewire{,-pulse}.{socket,service}    
systemctl --user --now enable pulseaudio.service pulseaudio.socket
muru
  • 207,228
1nfern0
  • 2,499
23

To add to 1nfern0's answer, pactl info was giving me a connection failure after following all the steps. I got around it by running: systemctl --user --now enable pipewire pipewire-pulse.

You may also need to restart your system once.

4

The answers above were important, there is one other thing that is possible which is that you have an old config file in /etc/pipewire/pipewire.conf which will prevent pipewire from properly working, I removed the entire /etc/pipewire directory and reinstalled pipewire and pipewire-pulse to resolve the issues and now things work.

3

I faced problem of Connection refuse

Connection failure: Connection refused
pa_context_connect() failed: Connection refused

I followed following modifed steps and was successful in replacing Pulseaudio with Pipewire

  1. Add the PipeWire PPA

    sudo add-apt-repository ppa:pipewire-debian/pipewire-upstream
    
  2. Install the pipewire-audio-client-libraries package

    sudo apt update
    sudo apt install pipewire pipewire-audio-client-libraries
    
  3. Install some additional libraries, to use a Bluetooth headset.

    sudo apt install gstreamer1.0-pipewire libpipewire-0.3-{0,dev,modules} libspa-0.2-{bluetooth,dev,jack,modules} pipewire{,-{audio-client-libraries,pulse,media-session,bin,locales,tests}}
    
  4. Reload the daemon in systemd

    systemctl --user daemon-reload
    
  5. Disable PulseAudio in Ubuntu

    systemctl --user --now disable pulseaudio.service pulseaudio.socket
    
  6. Start PipeWire and enable

    systemctl --user --now enable pipewire pipewire-pulse

  7. Command to ensure that PipeWire

    pactl info
    
muru
  • 207,228
2

After completing the steps described in 1nfern0's answer (when PipeWire is working), you can use the following Bash script to toggle between A2DP (high fidelity playback, with the microphone disabled) and mSBC (for usage as a headset, with the microphone enabled):

#!/bin/bash

Toggle your bluetooth device (e.g., Bose Headphones) between A2DP mode (high-fidelity playback with NO microphone) and HSP/HFP, codec mSBC (lower playback quality, microphone ENABLED)

function tbt { current_mode_is_a2dp=pactl list | grep Active | grep a2dp card=pactl list | grep "Name: bluez_card." | cut -d ' ' -f 2

if [ -n "$current_mode_is_a2dp" ]; then
    echo "Switching $card to mSBC (headset, for making calls)..."
    pactl set-card-profile $card headset-head-unit-msbc
else
    echo "Switching $card to A2DP (high-fidelity playback)..."
    pactl set-card-profile $card a2dp-sink
fi

}

The above script is an adaptation from: https://bbs.archlinux.org/viewtopic.php?pid=1973205#p1973205

BrunoF
  • 179
1

I was having issues (So many that I don't even know where to start). What worked for me:

After following all the steps above, I submitted on Terminal the following:

To restart Pulse Audio:

mv ~/.config/pulse/ ~/.config/pulse.old
systemctl --user restart pulseaudio
mv ~/.config/pulse/ ~/.config/pulse.old
pulseaudio --k && pulseaudio --start

To reinstall Pulse Audio:

sudo apt update
sudo apt install --reinstall -o Dpkg::Options::="--force-confmiss" pulseaudio
dpkg -L pulseaudio
rm $HOME/.config/pulse/*

Enabling Pipewire

systemctl --global --now enable pipewire{,-pulse}.{socket,service}
sudo systemctl --global --now enable pipewire{,-pulse}.{socket,service}
sudo systemctl --global --now enable pipewire pipewire-pulse
sudo systemctl --user --now enable pipewire pipewire-pulse
sudo systemctl --user --now enable pulseaudio.service pulseaudio.socket

Nuking pulseadio again:

sudo pkill pulseaudio
sudo /etc/init.d/bluetooth restart

I don't really know which one did the trick... but now after:

pactl info

I get:

Server String: /run/user/1000/pulse/native 
Library Protocol Version: 35
Server Protocol Version: 35
Is Local: yes
Client Index: 155
Tile Size: 65472
User Name: *
Host Name: *
Server Name: PulseAudio (on PipeWire 0.3.58)
Server Version: 15.0.0
Default Sample Specification: float32le 2ch 48000Hz
Default Channel Map: front-left,front-right
Default Sink: bluez_output.90_98_38_0B_87_BD.a2dp-sink
Default Source: alsa_input.pci-0000_00_1b.0.analog-stereo
Cookie: 2b71:d622

And all of this work because now ubuntu settings shows AAC codec for the Bluetooth device.

muru
  • 207,228
Tico
  • 11
  • 1
-1

I have had a bluetooth connect problem on and off with Linux Mint 21.1, which appeared to start with a kernel update, then went away with the latest kernel update. I was trying to make my Phonak hearing aids connect. I found today that I was able to connect by shutting down both hearing aids at the same time (open the battery compartments) and then turning them on again (close battery compartments) and immediately try to connect the right hearing aid. Maybe this will continue to work, maybe not. Hope this helps somebody.

Asked what this has to do with pipewire by mikewhatever. Legitimate question. The connection is indirect. HP laptop, Realtek RTL8821ce wifi/bluetooth card, once worked, stopped working with Linux Mint update, tried all sorts of things including installing pipewire, nothing worked until just 2 days ago when I took above steps, after yet another update of Linux Mint. Different people have different reasons for using the Q&A forum here. I was hoping to help the hearing impaired as they scroll through innumerable pages of solutions that didn't work for me with my bluetooth hearing aids.

RJS
  • 29