蓝牙配置文件锁定为 A2DP(高质量音频接收器)但无法更改为 HFP/HSP(低质量双向耳机)

Mik*_*ike 7 sound usb pulseaudio bluetooth headset

在 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
Run Code Online (Sandbox Code Playgroud)

在 Windows 10(双启动)下,一切正常,包括内置蓝牙适配器和 USB 加密狗蓝牙适配器。我有一堆同时支持 A2DP(仅高质量音频输出)和 HFP/HSP(低质量双向输入和输出)的耳机。在 Windows 10 下,会自动选择正确的蓝牙配置文件以与应用程序保持一致。

请注意,我正在运行 Gnome 3,而不是 Unity,目前版本为 3.26.2-0ubuntu0.1(Ubuntu 17.10 有现货)。

在17.04之前的Ubuntu 下,我可以从 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
Run Code Online (Sandbox Code Playgroud)

不行的是17.04发布后新配对的蓝牙耳机被锁定为A2DP,无法切换。两个配置文件都显示在 gnome-control-center 的相应下拉菜单中,但选择 HFP/HSP 没有效果,也不会保留。事实上,选择 HFP/HSP 然后使用“测试扬声器”显示一个左右声道,证明设备仍然处于 A2DP 模式(立体声)而不是 HFP/HSP 模式(单声道)。

以下是显示相关蓝牙耳机的“pactl list卡”输出示例:

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
Run Code Online (Sandbox Code Playgroud)

请特别注意“配置文件”块,其中“a2dp_sink”与“available:yes”一起列出,“headset_head_unit”与“available:no”一起列出。请记住,这不能直接来自设备,因为 (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
Run Code Online (Sandbox Code Playgroud)

我会对让这些耳机永久锁定到 HFP/HSP 并且在必要时从不使用 A2DP 感到满意,但我什至不知道如何做到这一点。

ayk*_*yke 11

编辑:也尝试使用 Blueman 连接。我不知道为什么 PulseAudio 有这么多麻烦,但只需打开 Blueman,在概览中右键单击我的耳机,然后选择 Audio Profile > Headset Head Unit (HSP/HFP) 即可为我修复。我已经停止并删除了 oFono,它似乎仍然有效。


我的 Bose QC35 II 遇到了类似(相同?)问题,并按照这些说明进行了修复(“将 HFP 与 oFono 配合使用”)。

我在 Debian buster 上,所以对你来说事情可能有点不同。

  1. 安装ofonoofono-phonesim

    sudo apt-get install ofono-phonesim
    
    Run Code Online (Sandbox Code Playgroud)
  2. 克隆 oFono Git 存储库(当前位于 cf850de632):

    git clone git://git.kernel.org/pub/scm/network/ofono/ofono.git
    cd ofono
    
    Run Code Online (Sandbox Code Playgroud)
  3. 列出您拥有的可用调制解调器:

    ./test/list-modems
    
    Run Code Online (Sandbox Code Playgroud)
  4. 它可能没有调制解调器,这在现代 Linux 桌面上并不奇怪。但出于我不太明白的原因,你真的需要某种调制解调器才能让耳机工作,所以我们现在要模拟一个。
    首先模拟一个(如果需要,您可以选择不同的端口):

    ofono-phonesim -p 12345 /usr/share/phonesim/default.xml
    
    Run Code Online (Sandbox Code Playgroud)
  5. 修改 /etc/ofono/phonesim.conf 以使用此模拟调制解调器。我的 Debian 版本太好了,已经在那里放了一些东西,但已将其注释掉。这就是我现在的样子(没有评论):

    [phonesim]
    Driver=phonesim
    Address=127.0.0.1
    Port=12345
    
    Run Code Online (Sandbox Code Playgroud)
  6. 重启oFono:

    sudo service ofono restart
    
    Run Code Online (Sandbox Code Playgroud)
  7. 检查设备现在是否已列出:

    ./test/list-modems
    
    Run Code Online (Sandbox Code Playgroud)
  8. 启用设备:

    ./test/enable-modem /phonesim
    
    Run Code Online (Sandbox Code Playgroud)

    如果您收到这样的错误,请确保您的 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
    
    Run Code Online (Sandbox Code Playgroud)

    检查设备现在是否已使用./test/list-modems.

希望它现在有效!您可能还需要重新启动其他服务(bluez、pulseaudio)。

我现在可以选择我的耳机作为输入设备。它会导致设备使用非常低质量的音频,但至少它可以工作。使用完麦克风后,请务必切换回“高保真播放(A2DP 接收器)”,否则您将获得非常低质量的音频输出。


Man*_*ele 1

就我而言,问题是由缺少驱动程序引起的。

尝试

lsusb | grep Bluetooth
Run Code Online (Sandbox Code Playgroud)

如果您的芯片组是 Broadcom BCM20702AX系列,请尝试

dmesg | grep -i bluetooth | grep -i firmware -A2
Run Code Online (Sandbox Code Playgroud)

就我而言,驱动程序丢失了,您可以在这里找到它。更多信息请点击此处