37

Since I have installed ubuntu 20.04 I am 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 not able to get to the correct steps.

Thanks a lot!

1nfern0
  • 2,209
  • 1
  • 12
  • 18
  • https://askubuntu.com/questions/1333404/how-to-replace-pulseaudio-with-pipewire-on-ubuntu-21-04 – jasmines May 21 '21 at 14:04
  • Does this answer your question? [How to replace pulseaudio with pipewire on Ubuntu 21.04?](https://askubuntu.com/questions/1333404/how-to-replace-pulseaudio-with-pipewire-on-ubuntu-21-04) – jasmines May 21 '21 at 14:04
  • @jasmines I tried this solution but my problem didn't resolve even after installing pipewire. Here is the file where you can see I am using AD2P and it doesn't detect my bluetooth headset microphone. https://imgur.com/a/hIZZwdY Isn't pipewire supposed to make AD2P work along with your microphone ? – 1nfern0 May 21 '21 at 14:16

9 Answers9

67

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-repository 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
  1. 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

Edit: 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
Rael Gugelmin Cunha
  • 6,745
  • 2
  • 34
  • 35
1nfern0
  • 2,209
  • 1
  • 12
  • 18
  • I've been having the same problem with my headset not being detected on Ubuntu 21.04. I tried this solution, but now there is no HSP/HFP option under for the headset in the sound settings. There is only A2DP Sink with codec AAC and A2DP with codec SBC. Any ideas as to why this is? – BenM May 23 '21 at 14:00
  • Did you try restarting you system? And also can you show me your output of : `pactl info` Also, you need to try restarting pipewire, unpair and pair your device. – 1nfern0 May 23 '21 at 14:03
  • Yes, I tried restarting my system. I also restarted Pipewire. The output of `pactl info`: Server String: /run/user/1000/pulse/native Library Protocol Version: 34 Server Protocol Version: 35 Is Local: yes Client Index: 83 Tile Size: 65472 User Name: ben Host Name: ben-desktop Server Name: PulseAudio (on PipeWire 0.3.28) Server Version: 14.0.0 Default Sample Specification: float32le 2ch 48000Hz Default Channel Map: front-left,front-right Default Sink: bluez_output.AC_12_2F_24_03_B1.a2dp-sink Default Source: bluez_output.AC_12_2F_24_03_B1.a2dp-sink.monitor Cookie: 0e10:4a04 – BenM May 23 '21 at 14:06
  • I am assuming your headset works perfectly fine with Windows and Android/Mac. Am i correct? – 1nfern0 May 23 '21 at 14:08
  • Yes, it works perfectly with Windows and Android (never tried with Mac or iOS) – BenM May 23 '21 at 14:09
  • Did you mask pulseaudio by: `systemctl --user mask pulseaudio` Your bluetooth service and pairing, unpairing device is working fine after installing pipewire? – 1nfern0 May 23 '21 at 14:16
  • Yes I did mask pulseaudio, and pairing/unpairing the headset is also working fine. – BenM May 23 '21 at 14:21
  • Can you try to switch the profiles to HSP/HFP by installing Bluetooth Manager ? Even when my microphone was not detected, I was able to see HSP/HFP profile but wasn't able to switch. This is a little strange. Install Blueman with this command: `sudo apt-get install -y blueman` – 1nfern0 May 23 '21 at 14:25
  • 1
    I have already tried switching the profile from Bluetooth Manager, but the HSP/HFP profile wasn't listed there either. However, I found the problem. I had tried using ofono to solve this issue a few weeks ago following the same AskUbuntu post you mentioned in your article, and I realised that I still had ofono installed. I just had to uninstall ofono, and now my microphone works perfectly using Pipewire. Thanks for all your help. I've been trying to get my mic to work on Ubuntu for quite a while. :) – BenM May 23 '21 at 14:35
  • Great to hear. I will update about this in the answer. Thanks for your info! – 1nfern0 May 23 '21 at 14:41
  • @jasmines it seems like pipewire service hasn't started in your system. I guess you might have missed some step in between. Can you show output of `pactl info` – 1nfern0 May 25 '21 at 11:51
  • @BenM, had a similar problem. HSP/HFP was working on Arch, but not on Ubuntu with pipewire. Solved by removing ofono. – Anton Kazennikov Jun 17 '21 at 17:11
  • This worked great with the Huawei Freebuds Pro! Thank you. I had to remove libldac, which had probably be installed before during the frustrated attempts to make it work with pulseaudio and was conflicting with the installation of libspa-0.2-bluetooth. Now audio works fine on all headsets and audio systems. Media files weirdly even seem to start playing smoother now. – DarkScrolls Jun 24 '21 at 20:08
  • When I tried to do this system-wide, it wouldn't work. How can I configure that to work? – YamiYukiSenpai Jun 29 '21 at 08:54
  • I want to ask is the quality when on hfp/hsp significantly worse than A2DP for people who managed to use this? I got it working and it is for me. – Geralt Aug 07 '21 at 01:34
  • @Gerait Yes, when I first got HFP/HSP working the audio was terrible. To get a bit better audio, you can enable the mSBC codec by uncommmenting the line in /etc/pipewire/media-session.d/bluez-monitor.conf that says `bluez.msbc-support = true`. Then select that audio codec in the Ubuntu sound settings. The audio still won't be as good as A2DP, but that's what happens when using a headset profile on headphones. – BenM Aug 09 '21 at 03:10
  • Worth noting that pulseaudio 15.0 should fix the issue with the "disappeared" bluetooth profile negotiation which supports the microphone with A2DP. See https://www.freedesktop.org/wiki/Software/PulseAudio/Notes/15.0/#supportforhfpbluetoothprofiles https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/491 and https://git.kernel.org/pub/scm/linux/kernel/git/stable/stable-queue.git/commit/?id=839e7ebed5b5354ffb623511a49499ca6707cd64 – Brad J Sep 13 '21 at 00:57
  • Just followed the instructions, but the volume controls on the keyboard stopped working. What fixed it was deleting/moving `.config/pulse` in my home directory. I now have the options of SBC, SBC-XQ and AAC for A2DP as well as CVSD and mSBC for HSP/HFP with Jabra Elite 85t. – Moritz Dec 02 '21 at 12:28
  • You might also need to `sudo apt remove pulseaudio-module-bluetooth` -- i've been having problems with bluetooth otherwise – Leo Alekseyev Jan 04 '22 at 23:03
  • Failed to enable unit: Unit file /etc/xdg/systemd/user/pipewire-media-session.service is masked. – mondjunge Mar 24 '22 at 09:42
  • You are a gentleman and a scholar. Thank yo ufor sharing this. It worked for me – Jesse Roper Jan 26 '23 at 16:26
  • No luck here - I saw that Pipewire is installed but no sound devices found at all (neither built-in Jack). After I reverted and uninstalled everything system was stuck on booting - no login screen. I was able to fix it by hitting `Ctrl + Alt + F2` and reinstalling Gnome `apt install --reinstall gnome` (maybe this will help someone else). – Jurosh Feb 22 '23 at 10:44
20

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.

Sudeepam Pandey
  • 301
  • 2
  • 2
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.

Baruch Even
  • 156
  • 2
  • 1
    In my case I have been installing earlier by another guides and it didn't work anything. I just followed the answer and removed. It works now. – Adrug Jan 03 '22 at 13:48
1

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
  • 159
  • 1
  • 6
0

pactl info was giving me a connection refuse (after following step 9 from the accepted answer on Ubuntu 20.04 LTS). I fixed by using wireplumber instead of pipewire-media-session-service.

Error404
  • 6,920
  • 1
  • 26
  • 50
  • 1
    Could you elaborate? How did you 'use' it instead? What if you already ran the enable command for pipewire-media-session-service? – Joseph Garvin May 21 '22 at 23:36
  • 1
    Just downvoted this answer because it's not clear on how to install/enable and use wireplumber in Ubuntu 20.04 – meetnick Nov 11 '22 at 17:56
0

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.

Hope this helps someone...

Tico
  • 1
0
➜  / sudo systemctl --global --now enable pipewire{,-pulse}.{socket,service}
Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user)
➜  / sudo systemctl --global --now enable pipewire pipewire-pulse
Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user)
➜  / sudo systemctl --user --now enable pipewire pipewire-pulse
Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user)
➜  / sudo systemctl --user --now enable pulseaudio.service pulseaudio.socket
Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user)
➜  / 
Pei JIA
  • 360
  • 2
  • 4
  • 12
0

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

Step 1 : Add the PipeWire PPA

$ sudo add-apt-repository ppa:pipewire-debian/pipewire-upstream

Step 2 : Install the pipewire-audio-client-libraries package

$ sudo apt update
$ sudo apt install pipewire pipewire-audio-client-libraries

Step 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}}

Step 4 : Reload the daemon in systemd

$ systemctl --user daemon-reload

Step 5 : Disable PulseAudio in Ubuntu

$ systemctl --user --now disable pulseaudio.service pulseaudio.socket

Step 6 : Start PipeWire and enable

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

Step 7 : Command to ensure that PipeWire

$ pactl info
Nitin Jadhav
  • 101
  • 2
0

i tried all of the above answers but i am still not getting mSBC codec

#bluez5.enable-sbc-xq = true #bluez5.enable-msbc = true #bluez5.enable-hw-volume = true #bluez5.enable-faststream = true

i have these enabled in the bluez-monitor.conf

available codecspactl info

  • 1
    This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://askubuntu.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://askubuntu.com/help/whats-reputation), you can also [add a bounty](https://askubuntu.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/1288961) – David Mar 25 '23 at 08:58