在 Ubuntu 20.04 上连接配对的蓝牙耳机时遇到问题

在 Ubuntu 20.04 上连接配对的蓝牙耳机时遇到问题

找不到可行的解决方案,请帮忙。蓝牙耳机可以配对,但无法连接。

$ bluetoothctl

# scan on
Discovery started
[CHG] Controller F0:85:C1:FF:BD:A8 Discovering: yes
[NEW] Device FC:58:FA:CF:D0:01 BT-1100
# scan off
Discovery stopped
[CHG] Controller F0:85:C1:FF:BD:A8 Discovering: no
[CHG] Device FC:58:FA:CF:D0:01 RSSI is nil
# devices
Device FC:58:FA:CF:D0:01 BT-1100
# pair FC:58:FA:CF:D0:01
Attempting to pair with FC:58:FA:CF:D0:01
[CHG] Device FC:58:FA:CF:D0:01 Connected: yes
[CHG] Device FC:58:FA:CF:D0:01 Connected: no
[CHG] Device FC:58:FA:CF:D0:01 Connected: yes
[CHG] Device FC:58:FA:CF:D0:01 UUIDs: 00001108-0000-1000-8000-00805f9b34fb
[CHG] Device FC:58:FA:CF:D0:01 UUIDs: 0000110b-0000-1000-8000-00805f9b34fb
[CHG] Device FC:58:FA:CF:D0:01 UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Device FC:58:FA:CF:D0:01 UUIDs: 0000111e-0000-1000-8000-00805f9b34fb
[CHG] Device FC:58:FA:CF:D0:01 ServicesResolved: yes
[CHG] Device FC:58:FA:CF:D0:01 Paired: yes
Pairing successful
[CHG] Device FC:58:FA:CF:D0:01 ServicesResolved: no
[CHG] Device FC:58:FA:CF:D0:01 Connected: no
# connect FC:58:FA:CF:D0:01
Attempting to connect to FC:58:FA:CF:D0:01
[CHG] Device FC:58:FA:CF:D0:01 Connected: yes
[CHG] Device FC:58:FA:CF:D0:01 Connected: no
Failed to connect: org.bluez.Error.Failed
[CHG] Device FC:58:FA:CF:D0:01 Connected: yes
[CHG] Device FC:58:FA:CF:D0:01 Connected: no

日志:

Jan 05 00:59:00 host1 bluetoothd[536]: Unable to get connect data for Headset Voice gateway: getpeername: Transport endpoint is not connected (107)
Jan 05 00:59:02 host1 bluetoothd[536]: connect error: Connection reset by peer (104)
Jan 05 00:59:37 host1 bluetoothd[536]: connect error: Connection reset by peer (104)

Pulseaudio 配置:

$ grep -P '(bluetooth|bluez)' /etc/pulse/default.pa /etc/pulse/system.pa
/etc/pulse/default.pa:#.ifexists module-bluetooth-policy.so
/etc/pulse/default.pa:load-module module-bluetooth-policy
/etc/pulse/default.pa:#.ifexists module-bluetooth-discover.so
/etc/pulse/default.pa:load-module module-bluetooth-discover
/etc/pulse/system.pa:load-module module-bluez5-device
/etc/pulse/system.pa:load-module module-bluez5-discover

安装的软件包:

$ dpkg -l | grep -P '(bluetooth|bluez)'
ii  blueman                              2.1.2-1ubuntu0.2                           amd64        Graphical bluetooth manager
ii  bluez                                5.53-0ubuntu3                              amd64        Bluetooth tools and daemons
ii  bluez-obexd                          5.53-0ubuntu3                              amd64        bluez obex daemon
ii  bluez-tools                          2.0~20170911.0.7cb788c-2build1             amd64        Set of tools to manage Bluetooth devices for linux
ii  libbluetooth3:amd64                  5.53-0ubuntu3                              amd64        Library to use the BlueZ Linux Bluetooth stack
ii  pulseaudio-module-bluetooth          1:13.99.1-1ubuntu3.8                       amd64        Bluetooth module for PulseAudio sound server
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.1 LTS
Release:        20.04
Codename:       focal

$ uname -a
Linux host1 5.4.0-59-generic #65-Ubuntu SMP Thu Dec 10 12:01:51 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

请帮忙。

答案1

tl;dr:我尝试了不同网络搜索结果的建议,但最终对我有用的是:我找到并杀死了多余的 pulseaudio 进程。

原文贴文如下:

我也遇到过这样的问题:pulseaudio 有时无法连接到我的蓝牙耳机,即使我做了以下操作之后仍然无法连接:

  • 使用以下命令终止 pulseaudio:
pulseaudio -k
  • 使用以下命令卸载模块蓝牙发现:
pactl unload-module module-bluetooth-discover
  • 删除 pulseaudio 配置:
rm -rf ~/.config/pulse

(实际上,我使用脚本将目录重命名为其他名称。)

  • 等待 6 秒(在我的脚本中)
  • 使用以下命令重新启动蓝牙服务:
sudo service bluetooth restart
  • 再次加载 module-blueoth-discover:
pactl load-module module-bluetooth-discover
  • 使用以下命令重新启动 pulseaudio:
pulseaudio

(实际上,它会自动重启,但是为了以防万一我还是决定重启它)

有时上述方法可以解决问题,但有时 pulseaudio 拒绝连接到蓝牙耳机,即使蓝牙连接本身显然存在,在 blueman-manager 下列出(并且耳机发出哔哔声以表明已连接)。

这是我今晚发现的:它失败是因为有多个 pulseaudio 副本正在运行。我发现了这一点:

ps -ef | grep puls

我杀掉了老的进程

kill 7734 

(或者上述命令输出的任何进程号ps -ef|grep pulse

希望这可以涵盖所有之前无法连接的情况。

顺便说一句,有时会有一个额外的副本在blueman-manager运行(即,在我运行“blueman-manager”命令之前已经有一个副本在运行),并且我还必须对其使用“kill”命令killall blueman-manager

不确定这是否有帮助,但我希望我的答案存在于可搜索的网络空间中的某个地方,因为我一直发现十几个对“pulseaudio 无法连接到我的蓝牙”的回应,但它们都没有解决我的问题。

相关内容