34

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
14

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.

25

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
7
  • Thank you. My sony SBH24 mic only works on HSP mode. This helps in auto-switching. – Rohit Karadkar May 29 '20 at 4:05
  • My Marshall MID works now! Thank you! – Serhii Polishchuk Sep 2 '20 at 6:25
  • This didn't work for my JBL LIVE650BTNC, do you know the reason? – Fabio Filho Oct 7 '20 at 13:45
  • seems to have locked my headphones into a HSP/HFP mode. But at least it now uses the mic consistently. – Ufos Nov 2 '20 at 18:35
  • Didn't work for airpods pro. Ugh. – Sephethus Dec 2 '20 at 15:19
7

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
  • 5
    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 Jan 31 '18 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 Feb 1 '18 at 13:44
  • en.wikipedia.org/wiki/… - it is inherent to the Bluetooth profile definition. Nothing we or any other OS could do to overcome this - but you are quite correct in that issues with HFP-mode sadly still exist. – Takkat Feb 1 '18 at 14:23
  • 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 Feb 2 '18 at 23:59
  • on Ubuntu 18.04 , i get the error "Failed to change profile to headset_head_unit" when i try to switch to HFP – kommradHomer Mar 24 '20 at 8:49
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 Aug 12 '20 at 15:48
  • I installed this on Mint 19 based on Ubuntu 18.04 LTS. – IvanTheFirst Aug 17 '20 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
0

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.