在 Acer 笔记本电脑上,我从来没有获得过对内置蓝牙适配器的有效支持——https://bugs.launchpad.net/ubuntu/+source/linux-firmware/+bug/1643455——最后放弃了,买了一个便宜的 USB 蓝牙适配器:
# lsusb -v -d 0a12:0001
Bus 002 Device 002: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 2.00
bDeviceClass 224 Wireless
bDeviceSubClass 1 Radio Frequency
bDeviceProtocol 1 Bluetooth
bMaxPacketSize0 64
idVendor 0x0a12 Cambridge Silicon Radio, Ltd
idProduct 0x0001 Bluetooth Dongle (HCI mode)
bcdDevice 88.91
iManufacturer 0
iProduct 2 CSR8510 A10
iSerial 0
bNumConfigurations 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 177
bNumInterfaces 2
bConfigurationValue 1
iConfiguration 0
bmAttributes 0xe0
Self Powered
Remote Wakeup
MaxPower 100mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 3
bInterfaceClass 224 Wireless
bInterfaceSubClass 1 Radio Frequency
bInterfaceProtocol 1 Bluetooth
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 3
Transfer Type Interrupt
Synch Type None
Usage Type Data
wMaxPacketSize 0x0010 1x 16 bytes
bInterval 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x02 EP 2 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x82 EP 2 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0040 1x 64 bytes
bInterval 1
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 224 Wireless
bInterfaceSubClass 1 Radio Frequency
bInterfaceProtocol 1 Bluetooth
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 1
Transfer Type Isochronous
Synch Type None
Usage Type Data
wMaxPacketSize 0x0000 1x 0 bytes
bInterval 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 1
Transfer Type Isochronous
Synch Type None
Usage Type Data
wMaxPacketSize 0x0000 1x 0 bytes
bInterval 1
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 1
bNumEndpoints 2
bInterfaceClass 224 Wireless
bInterfaceSubClass 1 Radio Frequency
bInterfaceProtocol 1 Bluetooth
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 1
Transfer Type Isochronous
Synch Type None
Usage Type Data
wMaxPacketSize 0x0009 1x 9 bytes
bInterval 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 1
Transfer Type Isochronous
Synch Type None
Usage Type Data
wMaxPacketSize 0x0009 1x 9 bytes
bInterval 1
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 2
bNumEndpoints 2
bInterfaceClass 224 Wireless
bInterfaceSubClass 1 Radio Frequency
bInterfaceProtocol 1 Bluetooth
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 1
Transfer Type Isochronous
Synch Type None
Usage Type Data
wMaxPacketSize 0x0011 1x 17 bytes
bInterval 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 1
Transfer Type Isochronous
Synch Type None
Usage Type Data
wMaxPacketSize 0x0011 1x 17 bytes
bInterval 1
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 3
bNumEndpoints 2
bInterfaceClass 224 Wireless
bInterfaceSubClass 1 Radio Frequency
bInterfaceProtocol 1 Bluetooth
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 1
Transfer Type Isochronous
Synch Type None
Usage Type Data
wMaxPacketSize 0x0019 1x 25 bytes
bInterval 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 1
Transfer Type Isochronous
Synch Type None
Usage Type Data
wMaxPacketSize 0x0019 1x 25 bytes
bInterval 1
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 4
bNumEndpoints 2
bInterfaceClass 224 Wireless
bInterfaceSubClass 1 Radio Frequency
bInterfaceProtocol 1 Bluetooth
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 1
Transfer Type Isochronous
Synch Type None
Usage Type Data
wMaxPacketSize 0x0021 1x 33 bytes
bInterval 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 1
Transfer Type Isochronous
Synch Type None
Usage Type Data
wMaxPacketSize 0x0021 1x 33 bytes
bInterval 1
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 1
bAlternateSetting 5
bNumEndpoints 2
bInterfaceClass 224 Wireless
bInterfaceSubClass 1 Radio Frequency
bInterfaceProtocol 1 Bluetooth
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x03 EP 3 OUT
bmAttributes 1
Transfer Type Isochronous
Synch Type None
Usage Type Data
wMaxPacketSize 0x0031 1x 49 bytes
bInterval 1
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x83 EP 3 IN
bmAttributes 1
Transfer Type Isochronous
Synch Type None
Usage Type Data
wMaxPacketSize 0x0031 1x 49 bytes
bInterval 1
Device Status: 0x0001
Self Powered
在 Windows 10(双启动)下,一切正常,包括内置蓝牙适配器和 USB 适配器蓝牙适配器。我有一堆支持 A2DP(仅高质量音频输出)和 HFP/HSP(低质量双向输入和输出)的耳机。在 Windows 10 下,会自动选择正确的蓝牙配置文件以与应用程序保持一致。
请注意,我运行的是 Gnome 3,而不是 Unity,当前版本为 3.26.2-0ubuntu0.1(Ubuntu 17.10 的标配)。
在 Ubuntu 下前17.04,我可以从 gnome-control-center 轻松手动在 A2DP 和 HFP/HSP 之间切换耳机。在 Ubuntu 的早期版本(例如 16.04)下配对的蓝牙耳机在 Ubuntu 升级后仍可在更高版本下正常工作。
我对 /etc/pulse/default.pa 进行了一些修改,使我的主耳机在连接时成为默认音频设备(取代笔记本电脑外壳上的内置扬声器和麦克风)。我通过取消注释并因此启用模块“module-switch-on-connect”的加载并通过唯一设备标识符手动将耳机指定为默认源和默认接收器来实现此目的:
set-default-sink bluez_sink.16_07_12_21_09_4B.headset_head_unit
set-default-source bluez_sink.16_07_12_21_09_4B.headset_head_unit
不起作用的是,自 17.04 发布以来新配对的蓝牙耳机被锁定为 A2DP,无法切换。 这两个配置文件都显示在 gnome-control-center 中的相应下拉菜单中,但选择 HFP/HSP 不起作用并且不会保留。 事实上,选择 HFP/HSP 然后使用“测试扬声器”会显示左声道和右声道,证明设备仍处于 A2DP 模式(立体声)而不是 HFP/HSP 模式(单声道)。
以下是“pactl list cards”输出的示例,显示相关的蓝牙耳机:
Name: bluez_card.FB_60_AD_59_5B_9E
Driver: module-bluez5-device.c
Owner Module: 33
Properties:
device.description = "Premium Earbuds"
device.string = "FB:60:AD:59:5B:9E"
device.api = "bluez"
device.class = "sound"
device.bus = "bluetooth"
device.form_factor = "hands-free"
bluez.path = "/org/bluez/hci0/dev_FB_60_AD_59_5B_9E"
bluez.class = "0x240408"
bluez.alias = "Premium Earbuds"
device.icon_name = "audio-handsfree-bluetooth"
device.intended_roles = "phone"
Profiles:
a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)
headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 20, available: no)
off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
Active Profile: a2dp_sink
Ports:
handsfree-output: Handsfree (priority: 0, latency offset: 0 usec)
Part of profile(s): a2dp_sink, headset_head_unit
handsfree-input: Handsfree (priority: 0, latency offset: 0 usec, not available)
Part of profile(s): headset_head_unit
特别注意“配置文件”块,其中“a2dp_sink”列为“可用:是”,而“headset_head_unit”列为“可用:否”。请记住,这不能直接来自设备,因为 (1) 这些耳机在 Windows 10 下按预期工作,并且 (2) 同一型号的耳机只有在与旧版 Ubuntu 配对时才能正常工作。四五种不同的耳机都经历了相同的结果,所以我相信它们没有缺陷。
尝试手动设置配置文件对于 A2DP 成功,但对于 HFP/HSP 失败并出现错误:
# pactl set-card-profile 8 a2dp_sink
# pactl set-card-profile 8 headset_head_unit
Failure: Input/Output error
如果有必要的话,我会满足于将这些耳机永久锁定到 HFP/HSP 并且永远不会使用 A2DP,但我甚至不知道如何做到这一点。
答案1
编辑:也可以尝试使用 Blueman 进行连接。我不知道 PulseAudio 为何会出现这么多问题,但只需打开 Blueman,在概览中右键单击我的耳机,然后选择音频配置文件 > 耳机主机 (HSP/HFP),问题就解决了。此后,我停止并删除了 oFono,它似乎仍能正常工作。
我的 Bose QC35 II 也遇到了类似(相同?)的问题,我按照以下步骤修复了它这些说明(“将 HFP 与 oFono 结合使用”)。
我使用的是 Debian buster,因此对你来说情况可能会有些不同。
安装
ofono
并ofono-phonesim
:sudo apt-get install ofono-phonesim
克隆 oFono Git 存储库(当前位于 cf850de632):
git clone git://git.kernel.org/pub/scm/network/ofono/ofono.git cd ofono
列出您可用的调制解调器:
./test/list-modems
它可能没有调制解调器,这在现代 Linux 桌面上并不奇怪。但出于我不太明白的原因,你确实需要某种调制解调器才能让耳机工作,所以我们现在要模拟一个。
首先模拟一个(如果你愿意,你可以选择不同的端口):ofono-phonesim -p 12345 /usr/share/phonesim/default.xml
修改 /etc/ofono/phonesim.conf 以使用此模拟调制解调器。我的 Debian 版本很贴心地在其中添加了一些东西,但将其注释掉了。这就是我现在的样子(没有注释):
[phonesim] Driver=phonesim Address=127.0.0.1 Port=12345
重启 oFono:
sudo service ofono restart
检查设备现在是否已列出:
./test/list-modems
启用设备:
./test/enable-modem /phonesim
如果你收到这样的错误,请确保你的手机卡已启动并正在运行:
Connecting modem /phonesim... Traceback (most recent call last): File "./test/enable-modem", line 20, in <module> modem.SetProperty("Powered", dbus.Boolean(1), timeout = 120) File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 70, in __call__ return self._proxy_method(*args, **keywords) File "/usr/lib/python3/dist-packages/dbus/proxies.py", line 145, in __call__ **keywords) File "/usr/lib/python3/dist-packages/dbus/connection.py", line 651, in call_blocking message, timeout) dbus.exceptions.DBusException: org.ofono.Error.Failed: Operation failed
检查设备现在是否已打开电源
./test/list-modems
。
希望它现在可以正常工作!您可能还需要重新启动其他服务(bluez,pulseaudio)。
现在我可以选择耳机作为输入设备。这将导致设备使用非常低质量的音频,但至少它可以工作。使用完麦克风后,请务必切换回“高保真播放(A2DP 接收器)”,否则您将获得非常低质量的音频输出。