60

I'm trying to use my headphones with my Ubuntu 13.10. My headphones are Nokia BH-905i, which can be connected via Bluetooth or green+pink wires.

If I use bluetooth, voice quality is terrible or microphone doesn't work. If I try to choose "Headset" option from In and Out tabs in Sound Settings, they're disabling each together.

In Out tab, I'm using "High sound quality A2DP", because it betters voice quality.

How could I get my microphone working? Sound out works fine.

2

11 Answers 11

49

As it was already pointed out that A2DP is unidirectional, you have to switch to HSP profile every time you need to use the microphone. But doing so manually is not ideal, and unless application sets media.role=phone for the stream (most non-voip apps don't), pulseaudio won't switch it automatically by default.

But starting from Pulseaudio v. 11.0, it's possible to automatically switch the profile whenever microphone access is requested by the application, but it's disabled by default.

  1. Find load-module module-bluetooth-policy line in /etc/pulse/default.pa
  2. Change it to load-module module-bluetooth-policy auto_switch=2

Now pulseaudio will switch the device profile to HSP whenever microphone access is requested and change it back to A2DP after stream is closed.

You need to reload pulseaudio module after this for the changes to take effect:

  1. pulseaudio -k
  2. pulseaudio -D
12
  • Thank you. My sony SBH24 mic only works on HSP mode. This helps in auto-switching. Commented May 29, 2020 at 4:05
  • 1
    This is really frustrating, why does linux not support a2dp w/ microphones like android? Commented Jan 17, 2021 at 20:15
  • 17
    Getting E: [pulseaudio] main.c: Daemon startup failed. error when tried pulseaudio -D
    – Yogi Katba
    Commented Jan 25, 2021 at 6:57
  • 7
    Try systemctl --user restart pulseaudio if Daemon startup fails.
    – backslashN
    Commented Oct 14, 2021 at 12:19
  • 1
    When we connect the same device to the mobile phone, we can listen to high-quality audio(probably A2DP) even while using a mic. Then how come its limitation of A2DP and not ubuntu?
    – Nilesh
    Commented Oct 18, 2021 at 8:19
27

By design, the Bluetooth A2DP profile is unidirectional. We can not use a microphone unless our headset and adapter were capable to be paired simultaneously on both HSP, and A2DP protocol, or the application switches from A2DP to HSP on demand.

See also this enlightning discussion on bug #508522.

10

I've just installed a solution for Bluetooth not selecting the mic on my Bose QC35 II on Ubuntu 16.04 LTS.

Since the internal mic on my Samsung laptop is too close to the fan audio sounds like inside an airplane for all participants in a videocall.

The solution is Blueman that adds functionality for Bluetooth.

Install it: sudo apt-get install blueman

I had to restart network-manager (sudo service network-manager restart) after WiFi stopped working (could be unrelated, but hey better have it just in case).

Blueman GUI

I can now switch to Headeset Head Unit (HSP/HFP) and choose the headset mic in Sound settings

Sound settings - input

Still a bit of a hassle when it does not switch automatically (like Android does) but it's still better than being in a Jumbojet storage!

6
  • 7
    The question was on getting the microphone to work in A2DP mode, which AFAIK still is not possible. Using a mic in HFP mode is rather trivial and should work OOB without any additional applications needed. If you needed blueman in addition to get it working there may be an issue with your audio setup in the fist place.
    – Takkat
    Commented Jan 31, 2018 at 12:48
  • Well Takkat, it's a known problem with using BT mic in headphones on Ubuntu so it's not an audio setup for the mic problem... And sorry I accidentially downvoted your answer yesterday, could not reverse it. =(
    – Valross.nu
    Commented Feb 1, 2018 at 13:44
  • 1
    I disagree here because most OS do make the switch between the two protocols without user interaction. As pointed out Android or Windows or ios switches automatically, where Ubuntu does not... So there is a solution in place for automation between the two...
    – Valross.nu
    Commented Feb 2, 2018 at 23:59
  • 2
    on Ubuntu 18.04 , i get the error "Failed to change profile to headset_head_unit" when i try to switch to HFP Commented Mar 24, 2020 at 8:49
  • 4
    When trying to set HSP/HPF, I get the following error: Failed to change profile to headset_head_unit shown in the footer of the Blueman. Any hint here?
    – xmar
    Commented May 27, 2020 at 15:02
5

Along with the steps mentioned above by @Glub, that is,

  1. Find load-module module-bluetooth-policy line in /etc/pulse/default.pa
  2. Change it to load-module module-bluetooth-policy auto_switch=2

I had to reset the Pulseaudio configs and restart the Pulseaudio module by

mv ~/.config/pulse/ ~/.config/pulse.old
systemctl --user restart pulseaudio
1

This - https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Bluetooth/#index5h2 helped for me. Don't forget to install ofono and ofono-phonesim and start service.

The necessity to provide a modem to oFono makes the headset setup rather cumbersome. If you do not have a GSM/UMTS modem connected to your system (like in most desktop environments), you need a modem emulator. Unfortunately oFono does not allow to use a mobile (hfp modem, see below) as a modem to support headsets.

The best emulator choice is "phonesim" because there is a version that is maintained together with ofono. Most distributions contain a package ofono-phonesim or similar while the git version can be found at git://git.kernel.org/pub/scm/network/ofono/phonesim.git.

To set up phonesim, first create or edit the file phonesim.conf in /etc/ofono. It should contain the following lines:

[phonesim]
Driver=phonesim
Address=127.0.0.1
Port=12345

Restart oFono and check with list-modems if the phonesim modem was found. Start phonesim with

ofono-phonesim -p 12345 /usr/share/phonesim/default.xml&

The paths to phonesim.conf and default.xml might be different if you compiled ofono and/or phonesim from source. Now you can enable the modem either by using the enable-modem script or by issuing the following command:

dbus-send --print-reply --system --dest=org.ofono /phonesim org.ofono.Modem.SetProperty string:"Powered" variant:boolean:"true"

list-modems should show that the modem is powered and online. If you want to play with the modem emulator, you can add the -gui option to the phonesim command. Then a GUI will pop up as soon as you enable the modem.

Once the modem is set up properly, you can connect your headset and the "Headset Head Unit (HSP/HFP)" profile should be available in pulseaudio.

2
  • How you were able to install phonesim? I'm trying to do it with apt-get on my Ubuntu 20.04 but I'm not successful...
    – Arxeiss
    Commented Aug 12, 2020 at 15:48
  • I installed this on Mint 19 based on Ubuntu 18.04 LTS. Commented Aug 17, 2020 at 8:57
1

Building on IvanTheFirst's answer, I created a script that will connect to my Bluetooth headphones with mic enabled, I also had to compile Phonesim as I could not find a package with it. and to save you some time these are the packages I had to install qtdeclarative5-dev,qt5-default.

#!/bin/bash

# https://www.freedesktop.org/wiki/Software/PulseAudio/Documentation/User/Bluetooth/#index5h2
# https://git.kernel.org/pub/scm/network/ofono/phonesim.git
# to compile phonesim project, install these packages 'qtdeclarative5-dev,qt5-default'
# enable job control
set -m

# retrieve process in the form "7260/phonesim"
PHONESIM=$(netstat -antp 2>/dev/null | grep phonesim | awk '{print $7}')

# extract process id
PHONESIM="${PHONESIM/\/phonesim/}"
if [ -n "$PHONESIM" ]; then
  echo killing old phonesim process [$PHONESIM] 
  kill -9 $PHONESIM
fi

echo "starting phonesim on port 12345"
phonesim -p 12345 /usr/share/phonesim/default.xml&

echo "enable modem"
exit_status=1
while [ $exit_status -ne 0 ]; do
  sudo dbus-send --print-reply --system --dest=org.ofono /phonesim org.ofono.Modem.SetProperty string:"Powered" variant:boolean:"true"
  exit_status=$?
done

echo "restart bluetooth"
sudo service bluetooth restart

# MAC_ADDRESS=$(hcitool scan | grep "Galaxy Buds" | awk '{print $1}')
MAC_ADDRESS=D8:55:75:67:D1:68

while [ -z $MAC_ADDRESS ]; do   
  MAC_ADDRESS=$(hcitool scan | grep "Galaxy Buds" | awk '{print $1}')
done

sleep 5
echo "connect to Galaxy Buds [$MAC_ADDRESS]"
bluetoothctl <<< "connect $MAC_ADDRESS
                  quit"

echo "reattach to phonesim process"
fg
1

A bit late to the party but since this stuff still doesn't work out of the box in linux. I'll add my experience here as well.

I bought an Asus BT400 dongle, it uses the Broadcom BCM20702A1 chip (usb device 0b05:17cb). I had the same problem as described in the OP. A2DP works fine (i.e. only output), HSP/HFP neither output or input.

I read about old bugs:

And the linked workaround/fix for a Plugable dongle (it uses the same chip).

My understanding of the problem wasn't getting any better, and downloading an arbitrary firmware, for a somewhat-related product, from a random AWS server seemed a bit shady.

Finally I came upon this GitHub gist, describing how to use the firmware from the Asus Windows driver:

Then it finally "clicked" for me: These Bluetooth dongles are not fully functional as delivered and they require firmware updates to work completely. The Windows driver bundle a myriad of firmware files for all variants the driver supports. I don't really know how MacOS does it, but I assume it works similarly.

So, simply downloading the latest driver from their download page and then extracting the correct firmware file and placing it (correctly named) in /lib/firmware/brcm/ fixed the problem.

TL;DR The Windows driver contains the required firmware file.

0

In Zoom, next to the mute/unmute button, there is an up arrow. When you click that, you will see the options for the input (speaker) device and the output (mic) device. In that select "Same as System" so that it will be corresponding to all other applications. Otherwise, you can select the device you want in those options - it gives all the options like "Built-in Analog Stereo", "JBL Go", "boAt Rockerz", etc. depending on your connected sound devices. These worked for me when I used bluetooth earphones.

0

Refer below link for solving all HFP issues. I followed below procedure and then changed profile to HSP/HFP, codec CSVD and my true wireless earbuds microphone started to work perfectly.

https://atish3604.medium.com/solved-bluetooth-headset-mic-not-working-detected-in-ubuntu-20-04-86a5236444d0

0

Use the fix by Yurri S, which also works on Bluetooth headphones:

So after having this issue with beautiful, but already annoying, 20.04, I found a solution in another post at SuperUser. In my case what helped me was:

  1. Use the following command to get the Audio Codec for your machine's model:

    cat /proc/asound/card*/codec* | grep Codec
    

    In my case I saw the following audio and video codecs:

    Codec: Realtek ALC233
    Codec: Nvidia GPU 94 HDMI/DP
    
  2. Go to www.kernel.org, look up the version of the codec, and get the full name of it. In my case, for Realtek ALC233 it's alc233-eapd.

  3. Create/update the /etc/modprobe.d/alsa-base.conf file, and add this line, replacing the model with your own:

    options snd-hda-intel model=alc233-eapd
    
  4. Reboot the machine.

After that download blueman using:

sudo apt-get install blueman

Then go to Bluetooth devices, right-click on the headset you're connected to, hover over Audio Profile and select Headset Head Unit.

0

I've installed Pipewire (this commands are for Ubuntu 21.04, but they can be easily adapted to previous versions of Ubuntu).

  1. install PPA with this commands:
sudo add-apt-repository ppa:pipewire-debian/pipewire-upstream
sudo apt-get update
  1. Install pipewire and several related utilities
sudo apt install pipewire pipewire-pulse \
  pipewire-tests pipewire-locales gstreamer1.0-pipewire libspa-0.2-bluetooth \
  libspa-0.2-jack pipewire-audio-client-libraries
  1. Disable pulseaudio
sudo systemctl disable --global pulseaudio
  1. Enable pipewire
sudo systemctl enable --global pipewire-pulse
  1. Check pipewire is integrated checking the output of this command
$ pactl info | grep "Server Name"
Server Name: PulseAudio (on Pipewire 0.3.35)

Now change it Settings -> Sound -> Output, select "Headset Head Unit (HSP/HFP)" and what you will see that on "Input" also changes the microphone.

Reference https://askubuntu.com/a/1350854/170833

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .