Cant connect bluetooth headphones linux

Настройка bluetooth стерео-наушников в Ubuntu Linux (8.04 & 7.10)

Привет!
Решил написать небольшую инструкцию, чтобы помочь нуждающимся в настройке bluetooth-наушников под Linux. Описанный способ гарантированно работает в Ubuntu 7.10 и 8.04. В других системах не должно возникнуть особых проблем, если имеются все необходимые компоненты (bluez, alsa, python).

В прошлом году я купил себе bluetooth стерео-наушники (+гарнитура) Plantronics 590A. Отличные наушники — хорошее качество звука и полная свобода от проводов. После перехода с Windows XP на Ubuntu возник вопрос использования наушников, как в качестве обычных наушников для вывода звука, так и полноценной гарнитуры для общения в играх и в Skype.

Хотя стандартный bluetooth-менеджер Ubuntu, вроде как, подразумевает использование Audio Service для соответствующих bt-устройств, но я не смог быстро найти внятную инструкцию, как же организовать вывод звука на наушники.

Вскоре мне на глаза попалась замечательная программа BlueMan bluetooth manager (screenshots). Эта программа достойна отдельной статьи, так как у неё очень много возможностей и она очень облегчает жизнь любому, кому потребуется работа с различными устройствами через протокол bluetooth. Программа работает «поверх» стандартного Ubuntu-овского bt-стека bluez и практически не тянет за собой зависимостей (программа написана на python`e).
Перечислять все возможности программы я не стану, ограничусь только тем, что программа поддерживает bt-устройства с профилем A2DP

Всё что необходимо сделать в BlueMan — «спарить» ваши bt-наушники с программой. После «спаринга» я дополнительно активировал в параметрах программы использование службы звука.

В настройках службы звука я активировал использовал служб Headset, Sink, Control для своих наушников. Для обычного вывода звука вполне достаточно службы Headset. Остальные службы присутствуют, я так думаю, для поддержки работы bt-профиля AVRCP. Я не проверял работу профиля ни в одной программе в Ubuntu, так что о его работоспособности сказать ничего не могу.

Последним шагом необходимо подправить файлик

/.asoundrc. Я не большой коппенгаген в конфигурационном файле ALSA, все правки были подсмотрены из статей:

  1. http://alfa2linux.blogspot.com/2008/03/my-jabra-finally-working-with-bluez.html
  2. http://wiki.bluez.org/wiki/HOWTO/AudioDevices

Я не ставил никаких дополнительных пакетов, которые были упомянуты в статьях — bluetooth-alsa, btsco и др.

В файл .asoundrc я добавил такие строки:

Источник

Bluetooth headset

Currently, Arch Linux supports the A2DP profile (Audio Sink) for remote audio playback with the default installation.

Contents

Headset via Pipewire

PipeWire acts as a drop-in replacement for PulseAudio and offers an easy way to set up Bluetooth headsets. It includes out-of-the-box support for A2DP sink profiles using SBC/SBC-XQ, AptX, LDAC or AAC codecs, and HFP/HSP.

The daemon will be started automatically as a user service. Use pavucontrol or your desktop environment’s settings for configuration. For more information, see PipeWire#Bluetooth devices.

Battery level reporting

To get the current battery level of your headset reported to upower , the bluetoothd daemon must be started with experimental features.

This can be done by creating a replacement unit file for bluetooth.service and appending -E to the ExecStart line. Reload the service afterwards.

Headset via Bluez5/PulseAudio

This article or section is a candidate for merging with Bluetooth.

Install the pulseaudio-alsa , pulseaudio-bluetooth and bluez-utils packages, the last of which provides the bluetoothctl utility.

Configuration via CLI

Now we can use the bluetoothctl command line utility to pair and connect. For troubleshooting and more detailed explanations of bluetoothctl see the Bluetooth article. Run

to be greeted by its internal command prompt. Then enter:

Now make sure that your headset is in pairing mode. It should be discovered shortly. For example,

shows a device that calls itself «Lasmex LBT10» and has MAC address «00:1D:43:6D:03:26». We will now use that MAC address to initiate the pairing:

After pairing, you also need to explicitly connect the device (if this does not work, try the trust command below before attempting to connect):

Читайте также:  Ссылка смерти windows 10

If you are getting a connection error org.bluez.Error.Failed retry by killing existing PulseAudio daemon first:

Finally, if you want to automatically connect to this device in the future:

If everything works correctly, you now have a separate output device in PulseAudio.

You can now redirect any audio through that device using the «Playback» and «Recording» tabs of pavucontrol .

You can now disable scanning again and exit the program:

Setting up auto connection

To make your headset auto connect you need to enable PulseAudio’s switch-on-connect module. Do this by adding the following lines to /etc/pulse/default.pa :

Media controls

To use the media controls they may be forwarded to MPRIS, where they can be picked up by media players that support MPRIS for external control. See MPRIS#Bluetooth for details.

Configuration via GNOME Bluetooth

You can use GNOME Bluetooth graphical front-end to easily configure your bluetooth headset.

First, you need to be sure that bluetooth.service systemd unit is running.

Open GNOME Bluetooth and activate the bluetooth. After scanning for devices, you can connect to your headset selecting it on the device list. You can directly access to sound configuration panel from the device menu. On the sound panel, a new sink should appear when your device is connected.

LDAC/aptX

LDAC/aptX codec support can be enabled by installing pulseaudio-modules-bt AUR and libldac , and restarting PulseAudio. See its project page for configuration tips. You can verify the codec you are using for connection as follows:

Troubleshooting

Bad sound / Static noise / «Muddy» sound

If you experience bad sound quality with your headset, it could in all likelihood be because your headset is not set to the correct profile. See #Switch between HSP/HFP and A2DP setting to solve the problem.

Selected audio profile, but headset inactive and audio cannot be redirected

Deceptively, this menu is available before the device has been connected; annoyingly it will have no effect. The menu seems to be created as soon as the receiver recognizes the device.

Make sure to run bluetoothctl as root and connect the device manually. There may be configuration options to remove the need to do this each time, but neither pairing nor trusting induce automatic connecting for me.

Pairing fails with AuthenticationFailed

If pairing fails, you can try enabling or disabling SSPMode with:

You may need to turn off BlueTooth while you run this command.

Pairing works, but connecting does not

You might see the following error in bluetoothctl:

To further investigate, check the unit status of bluetooth.service or have a look at the log as follows:

You might see a message like this:

This may be due to the pulseaudio-bluetooth package not being installed (or pulseaudio-modules-bt-git AUR needing a clean reinstall). Install it if it missing, then restart pulseaudio.

It can also be due to permission, especially if starting pulseaudio as root allows you to connect. Add your user to the lp group, then restart pulseaudio. See /etc/dbus-1/system.d/bluetooth.conf for reference.

If the issue is not due to the missing package, the problem in this case is that PulseAudio is not catching up. A common solution to this problem is to restart PulseAudio. Note that it is perfectly fine to run bluetoothctl as root while PulseAudio runs as user. After restarting PulseAudio, retry to connect. It is not necessary to repeat the pairing.

If restarting PulseAudio does not work, you need to load module-bluetooth-discover.

The same load-module command can be added to /etc/pulse/default.pa .

If that still does not work, or you are using PulseAudio’s system-wide mode, also load the following PulseAudio modules (again these can be loaded via your default.pa or system.pa ):

It is also possible there are no write permissions for the owner of /var/lib/bluetooth/ . If this is the case, you may get the device to work by removing and re-pairing it, but the issue will return after rebooting. Restoring write permissions fixes this issue:

Connecting works, but there are sound glitches all the time

This is very likely to occur when the Bluetooth and the WiFi share the same chip as they share the same physical antenna and possibly band range (2.4GHz). Although this works seamlessly on Windows, this is not the case on Linux.

A possible solution is to move your WiFi network to 5GHz so that there will be no interference. If your card/router does not support this, you can upgrade your WiFi drivers/firmware. This approach works on Realtek 8723BE and latest rtl drivers for this chip from AUR.

If nothing of the previous is possible, a less effective mitigation is to tweak the fragment size and the latency on PulseAudio output port, trying to compensate interference. Reasonable values must be chosen, because these settings can make the audio out of sync (e.g. when playing videos). To change the latency of the bluetooth headset’s port (e.g. to 125000 microseconds in the following example):

Читайте также:  Eclipse для android с windows

where the identifier of the card can be found with

The fragment size can be set in the config file /etc/pulse/daemon.conf and takes effect after a restart of PulseAudio (for more details please see PulseAudio/Troubleshooting#Setting the default fragment number and buffer size in PulseAudio).

Perhaps it will help to add options ath9k btcoex_enable=1 to the /etc/modprobe.d/ath9k.conf (with the appropriate bluetooth adapter):

Connecting works, but I cannot play sound

Make sure that you see the following messages in your system log:

If you see a message similar to this, you can go on and investigate your PulseAudio configuration. Otherwise, go back and ensure the connection is successful.

This article or section is a candidate for moving to PulseAudio/Troubleshooting.

When using GDM, another instance of PulseAudio is started, which «captures» your bluetooth device connection. This can be prevented by masking the pulseaudio socket for the GDM user by doing the following:

On next reboot the second instance of PulseAudio will not be started.

It may happen that bluez wrongly considers an headset as not a2dp capable. In this case, search the index of the bluetooth device with

Among the output there should be a section related to the bluetooth headset, containing something similar to

To manually set the profile, run

where 2 is the index of the device retrieved through pacmd ls .

Connecting works, sound plays fine until headphones become idle, then stutters

If the headphones play sound correctly until they become idle and then stutter on resume (e.g. because the sound is paused, or because no sound is played for a while), try disabling PulseAudio’s automatic sink/source suspension on idle.

Some user reports huge delays or even no sound when the Bluetooth connection does not send any data. This is due to the module-suspend-on-idle module, which automatically suspends sinks/sources on idle. As this can cause problems with headset, the responsible module can be deactivated.

To disable loading of the module-suspend-on-idle module, comment out the following line in the configuration file in use (

/.config/pulse/default.pa or /etc/pulse/default.pa ):

Finally restart PulseAudio to apply the changes.

UUIDs has unsupported type

During pairing you might see this output in bluetoothctl:

This message is a very common one and can be ignored.

PC shows device as paired, but is not recognized by device

This might be due to the device not supporting bluetooth LE for pairing.

Try setting ControllerMode = bredr in /etc/bluetooth/main.conf . See [2].

Device connects, then disconnects after a few moments

If you see messages like the following in the journal, and your device fails to connect or disconnects shortly after connecting:

This may be because you have already paired the device with another operating system using the same bluetooth adapter (e.g., dual-booting). Some devices cannot handle multiple pairings associated with the same MAC address (i.e., bluetooth adapter). You can fix this by re-pairing the device. Start by removing the device:

Then restart bluetooth.service , turn on your bluetooth adapter, make your device discoverable, re-scan for devices, and re-pair your device. Depending on your bluetooth manager, you may need to perform a full reboot in order to re-discover the device.

Apple AirPods have low volume

Create a drop-in file for bluetooth.service with the following contents:

Then, restart bluetooth.service , reload its configuration, and reconnect your headset.

Additionally, for AirPods Pro, disable the spatial audio and enable Mono in the settings of your iPhone.

Apple AirPods Pro working with PulseAudio as A2DP Sink but not with HSP/HFP

If you find that AirPods Pro are working with PulseAudio, but are incapable of using the HSP/HFP configurations (in pavucontrol‘s Configurations tab, usually listed as unavailable), try switching to pipewire-pulse .

Note that switching to pipewire-pulse (and restarting your computer or the appropriate user-level systemd services) should enable HSP/HFP, but may also disable A2DP. (When selecting A2DP Sink in the Configurations tab, the option is instantly deselected and becomes Off.) If you encounter this issue, try removing/renaming the /var/lib/bluetooth folder like so:

Re-pair your AirPods Pro (and other devices) afterwards. This should make all configurations (HSP/HFP and A2DP) available again and easily accessible from pavucontrol and pacmd.

HSP problem: the bluetooth sink and source are created, but no audio is being transmitted

You may be missing firmware or the SCO (audio protocol of HSP and HFP) routing might be wrong. See [3] — the firmware for BCM20702 can be installed via bcm20702a1-firmware AUR or bcm20702b0-firmware AUR .

Читайте также:  Не включается windows config system

Error: Failed to start discovery org.bluez.Error.InProgress

If your headset is discovered, but fails to connect with the error «Failed to start discovery org.bluez.Error.InProgress», install bluez-hciconfig AUR and run

where X is the identifier of your computer’s bluetooth device (typically 0).

You should then be able to connect following the steps in #Configuration via CLI.

Switch between HSP/HFP and A2DP setting

This can easily be achieved by the following command where the card_number can be obtained by running pacmd list-cards .

For enabling automatic profile switching from A2DP to HSP when a recording stream appears without any role set, you can append auto_switch=2 to load-module module-bluetooth-policy in /etc/pulse/default.pa .

For more information about PulseAudio profiles, see PulseAudio Documentation.

A2DP not working with PulseAudio

Socket interface problem

If PulseAudio fails when changing the profile to A2DP with bluez 4.1+ and PulseAudio 3.0+, you can try disabling the Socket interface from /etc/bluetooth/main.conf by removing the line Enable=Socket and adding line Disable=Socket .

A2DP sink profile is unavailable

When the A2DP sink profile is unavailable it will not be possible to switch to the A2DP sink (output) with a PulseAudio front-end and the A2DP sink will not even be listed. This can be confirmed with pactl .

Trying to manually set the card profile with pacmd will fail.

This is known to happen from version 10.0 of Pulseaudio when connecting to Bluetooth headphones via Bluedevil or another BlueZ front-end. See related bug report.

This issue also appears after initial pairing of Headphones with some Bluetooth controllers (e.g. 0a12:0001, Cambridge Silicon Radio ) which might default to the Handsfree or Headset — HS service and will not allow switching to the A2DP PulseAudio sink that requires the AudioSink service.

  • For some headsets, using the headset’s volume or play/pause controls while connected can trigger the A2DP profile to become available.
  • It is possible that connecting to a headset via bluetoothctl from bluez-utils will make the A2DP sink profile available. There is an automation for this every time a bluetooth device is connected: fix-bt-a2dpAUR (detailed usage)
  • Manually switching to Bluetooth’s AudioSink service which would make the A2DP profile and its A2DP PulseAudio sink available. This can be done with blueman-manager which included in blueman or by registering the UUID of the AudioSink service with bluetoothctl .
  • Disable the headset profile
  • Enable MultiProfile support. This may help with headsets that support A2DP as well as Headset audio.
  • Sometimes, none of the steps above will work. You may have tried rebooting and powering bluetooth off and on to no avail. In this case, try restarting the bluetooth.service .
  • Alternatively, replacing pulseaudio-bluetooth with pulseaudio-modules-btAUR or pulseaudio-modules-bt-gitAUR , which provides additional Bluetooth codecs, may resolve the issue.

Gnome with GDM

This article or section is a candidate for merging with #Connecting works, but I cannot play sound.

The instructions below were tested on Gnome 3.24.2 and PulseAudio 10.0 however they may still be applicable and useful for other versions.

If PulseAudio fails when changing the profile to A2DP while using GNOME with GDM, you need to prevent GDM from starting its own instance of PulseAudio:

  • Prevent Pulseaudio clients from automatically starting a server if one is not running by adding the following:
  • Prevent systemd from starting Pulseaudio anyway with socket activation:
  • Restart, and check that there is no PulseAudio process for the gdm user using:

Further discussion about this problem and alternative fixes can be found at [4] and [5]. Alternatively, one may try and install fix-bt-a2dp AUR .

HFP not working with PulseAudio

HFP-only bluetooth headsets may not be usable in the standard configuration of PulseAudio. The respective profiles occur, but they are not available:

  • bluetoothctl info output shows:
  • pactl list of respective device shows:

To solve the respective issue, update to pulseaudio (>=13) and potentially pulseaudio-modules-bt-git AUR and bluez (>=5.5) to latest versions. Then install ofono AUR (start and enable using systemctl) and phonesim AUR and create / activate a fake modem as described here [6]:

  • Create /etc/ofono/phonesim.conf with:
  • Start as user:
  • Enable and start ofono service.
  • Power modem:
  • Activate modem:
  • To check the results, use the test commands from ofonoAUR installed in /usr/lib/ofono/test/ . To power, activate, and test the modem you can use:

The output of the respective modem section should read like this:

  • Finally, restart pulseaudio and reconnect headset. Now, HFP should be available:

Disable auto switching headset to HSP/HFP

When using a bluetooth headset that supports multiple profiles, some applications switch to HSP/HFP profile automatically. If this behaviour is undesired you can disable this by appending the auto_switch=false parameter to the bluetooth-policy module:

Источник

Оцените статью