Bug 1167940

Summary: Cannot switch profile of Bluetooth headsets to HFP from A2DP
Product: [openSUSE] openSUSE Distribution Reporter: Fuminobu Takeyama <ftake>
Component: SoundAssignee: Takashi Iwai <tiwai>
Status: RESOLVED FIXED QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P2 - High CC: acho, aherzig, fcrozat, ftake, jcaamano, lubos.kocman, mike.sanders, mkoutny, msuchanek, oholecek, rombert, seife, stakanov, tiwai
Version: Leap 15.2   
Target Milestone: ---   
Hardware: Other   
OS: Other   
Whiteboard:
Found By: --- Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Attachments: no wireless mic (headset)
hwinfo and lsusb

Description Fuminobu Takeyama 2020-03-28 07:33:51 UTC
I have two Bluetooth headsets supporting A2DP and HSP/HFP. They works fine with A2DP profile. However, I cannot switch them to HSP/HFP profile to use their microphone.

I've tested under 3 environments
- Leap 15.1 with a on-board Bluetooth adapter 
- Leap 15.1 + latest Bluez and PulseAudio with a on-board Bluetooth adapter
- Leap 15.2 with a USB dongle (CSR8510 A10)

% LANG=C pactl set-card-profile bluez_card.30_A8_DB_77_4C_03 headset_head_unit
Failure: Input/Output error

% pactl list cards
(SNIPPED)
Card #1
        Name: bluez_card.30_A8_DB_77_4C_03
        Driver: module-bluez5-device.c
        Owner Module: 25
        Properties:
                device.description = "SBH50"
                device.string = "30:A8:DB:77:4C:03"
                device.api = "bluez"
                device.class = "sound"
                device.bus = "bluetooth"
                device.form_factor = "headset"
                bluez.path = "/org/bluez/hci0/dev_30_A8_DB_77_4C_03"
                bluez.class = "0x240404"
                bluez.alias = "SBH50"
                device.icon_name = "audio-headset-bluetooth"
                device.intended_roles = "phone"
        Profiles:
                a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 40, available: yes)
                headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 30, available: no)
                off: オフ (sinks: 0, sources: 0, priority: 0, available: yes)
        Active Profile: a2dp_sink
        Ports:
                headset-output: Headset (priority: 0, latency offset: 0 usec)
                        Part of profile(s): a2dp_sink, headset_head_unit
                headset-input: Headset (priority: 0, latency offset: 0 usec, not available)
                        Part of profile(s): headset_head_unit
Comment 1 Fuminobu Takeyama 2020-03-28 08:15:58 UTC
Found a message from PulseAudio

W: [pulseaudio] module-bluez5-device.c: Refused to switch profile to headset_head_unit: Not connected

These might related:
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/issues/84
https://github.com/pulseaudio/pulseaudio/compare/v13.0...paravoid:hfp-v7
Comment 2 Fuminobu Takeyama 2020-03-29 11:39:13 UTC
I have created a package to which the following patches applied. It works almost fine to me.
https://github.com/pulseaudio/pulseaudio/compare/v13.0...paravoid:hfp-v7

https://build.opensuse.org/project/show/home:ftake:btheadset


However, I am not sure how to reproduce but A2DP sometimes becomes "available: no". By reconnecting the headset, it becomes available again.


Note: SBH50 supports HFP profile and does not support HSP profile. To use HFP headset with current Bluez + PulseAudio, we need oFono and a phone emulator, which is difficult to set up.

Head set with HSP profile support might work with current PulseAudio and Bluez.


Another patch is available at:
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/94
Comment 3 Takashi Iwai 2020-03-29 17:26:31 UTC
Thanks for the follow up information.

Yes, HPF is a known problem, and it's good to know that we have a working patch set.

IMO, we can merge those patches into our pulseaudio package although it's not merged to upstream yet.  The lack of functionality is a bigger problem.

Adding more people to Cc for judging about this.
Comment 4 Stefan Seyfried 2020-03-29 19:22:05 UTC
I have a Sony SBH-52 which I can use for testing.
Comment 5 Takashi Iwai 2020-04-03 16:15:59 UTC
I got a cheap BT headset, so I started playing with it now, too.
HSF worked on mine, so obviously I couldn't reproduce the issue, but at least I could confirm that it still works with the patched packages on Leap 15.1 and Leap 15.2.

I also started hacking with the downstream pulseaudio-modules-bt package with HFP patches.  The result is found in OBS home:tiwai:bluetooth repo.  It contains pulseaudio-modules-bt package (strangely it's plural "modules") that supports aptX and other codecs.  If anyone is bored at home, please give it a try.
  https://build.opensuse.org/project/show/home:tiwai:bluetooth
Comment 6 Fuminobu Takeyama 2020-04-04 16:05:44 UTC
I tried pulseaudio-modules-bt on Leap 15.1 but I got the following errors by running

Apr 05 00:42:03 linux-qec9.suse pulseaudio[11558]: E: [pulseaudio] ltdl-bind-now.c: Failed to open module /usr/lib64/pulse-13.0/modules/module-bluez5-discover.so: libbluez5-util.so: 共有オブジェクトファイルを開けません: そのようなファイルやディレクトリはありません
Apr 05 00:42:03 linux-qec9.suse pulseaudio[11558]: E: [pulseaudio] module.c: Failed to open module "module-bluez5-discover".
Apr 05 00:42:03 linux-qec9.suse pulseaudio[11558]: E: [pulseaudio] module.c: Failed to load module "module-bluetooth-discover" (argument: ""): initialization failed.


% ls /usr/lib64/pulse-13.0/modules/ | grep bluez5
libbluez5-util.so*
module-bluez5-device.so*
module-bluez5-discover.so*

I've never though LDAC is available on Linux. Unfortunately, I don't have any device supporting LDAC for now.
Comment 7 Takashi Iwai 2020-04-04 18:00:31 UTC
Sorry, I've never tried Leap 15.1 install of this package but checked only the build, so it's no wonder that it doesn't work.  At least it worked on my Leap 15.2 system, though.
Comment 8 Lubos Kocman 2020-04-06 11:56:33 UTC
Hello Takashi I have beoplay e8 (3rd gen) and I'm also not able to use internal mic with high fidelity audio.

Testing your changes Takashi, otherwise I can confirm the same behavior as on the leap 15.2 (without testing your changes).
Comment 9 Lubos Kocman 2020-04-06 12:01:44 UTC
Hmmm so the first observation is that I can no lnger see the beoplay microphone in any mode now.
Comment 10 Lubos Kocman 2020-04-06 12:25:26 UTC
Oky so correction after short discussion with Takashi

HW
https://www.bang-olufsen.com/en/earphones/beoplay-e8-3rd-gen

Sound Codecs
SBC, AAC codec, Aptx

lkocman@linux:~> rpm -qa | egrep "bluez|libbluetooth|pulseaudio"
bluez-5.54-lp152.2.1.x86_64
pulseaudio-13.0-lp152.1.2.x86_64
pulseaudio-lang-13.0-lp152.1.2.noarch
pulseaudio-module-x11-13.0-lp152.1.2.x86_64
pulseaudio-gdm-hooks-13.0-lp152.1.2.x86_64
libbluetooth3-5.54-lp152.2.1.x86_64
pulseaudio-modules-bt-1.3-lp152.4.1.x86_64
pulseaudio-module-zeroconf-13.0-lp152.1.2.x86_64
pulseaudio-utils-13.0-lp152.1.2.x86_64
pulseaudio-bash-completion-13.0-lp152.1.2.x86_64
lkocman@linux:~> 

I can see all of these. For some reason if I switch from SBC to APTX (or similar switch) the audio gets switched from beoplay to line-out. So I have to manually switch it back.

I see APTX HD, LDAC options which are not really supported by my headset (see list above).

Otherwise I still can't choose the microphone on beoplay. I have only usb mic and internal mic options. I did check all modes including HPF.

See updated screenshot.
Comment 11 Lubos Kocman 2020-04-06 12:31:17 UTC
Created attachment 834955 [details]
no wireless mic (headset)
Comment 12 Takashi Iwai 2020-04-06 15:09:46 UTC
It seems that the dynamic switching doesn't work reliably sometimes.
In my case, choosing HFP right after the connection, then it can be switched in both modes.

I can confirm that, after changing the BT profile, the active stream is moved once to another sink/source, but you can bring it back.  I guess this is some racy condition.
Comment 13 Lubos Kocman 2020-04-06 22:02:26 UTC
Switching codecs (more likely cycling) while listening to audio stream also leads to a crash of bluetooth daemon

[  278.280367] Bluetooth: hci0: Bootloader revision 0.1 build 42 week 52 2015
[  278.281448] Bluetooth: hci0: Device revision is 2
[  278.281452] Bluetooth: hci0: Secure boot is enabled
[  278.281454] Bluetooth: hci0: OTP lock is enabled
[  278.281455] Bluetooth: hci0: API lock is enabled
[  278.281457] Bluetooth: hci0: Debug lock is disabled
[  278.281459] Bluetooth: hci0: Minimum firmware build 1 week 10 2014
[  278.287890] Bluetooth: hci0: Found device firmware: intel/ibt-18-16-1.sfi
[  280.080455] Bluetooth: hci0: Waiting for firmware download to complete
[  280.081355] Bluetooth: hci0: Firmware loaded in 1759682 usecs
[  280.081559] Bluetooth: hci0: Waiting for device to boot
[  280.094388] Bluetooth: hci0: Device booted in 12666 usecs
[  280.094524] Bluetooth: hci0: Found Intel DDC parameters: intel/ibt-18-16-1.ddc
[  280.097459] Bluetooth: hci0: Applying Intel DDC parameters completed
[  292.186182] input: Beoplay E8 (AVRCP) as /devices/virtual/input/input28
[  505.769302] show_signal_msg: 42 callbacks suppressed
[  505.769307] bluetoothd[2384]: segfault at 8 ip 000055cbc1e346e0 sp 00007ffd234a2ca8 error 4 in bluetoothd[55cbc1e09000+104000]
[  505.769320] Code: 1f 84 00 00 00 00 00 0f 1f 00 0f b6 07 c3 66 66 2e 0f 1f 84 00 00 00 00 00 90 0f b6 47 01 c3 66 66 2e 0f 1f 84 00 00 00 00 00 <48> 8b 47 08 c3 66 66 2e 0f 1f 84 00 00 00 00 00 8d 47 ff 41 56 41
[  574.271319] usb 1-4: USB disconnect, device number 4
[  576.163321] Bluetooth: hci0: command 0x0c03 tx timeout
[  577.168406] Bluetooth: hci0: HCI reset during shutdown failed
lkocman@linux:~>
Comment 14 Al Cho 2020-04-07 08:15:04 UTC
(In reply to Lubos Kocman from comment #13)
> Switching codecs (more likely cycling) while listening to audio stream also
> leads to a crash of bluetooth daemon
> 
> [  278.280367] Bluetooth: hci0: Bootloader revision 0.1 build 42 week 52 2015
> [  278.281448] Bluetooth: hci0: Device revision is 2
> [  278.281452] Bluetooth: hci0: Secure boot is enabled
> [  278.281454] Bluetooth: hci0: OTP lock is enabled
> [  278.281455] Bluetooth: hci0: API lock is enabled
> [  278.281457] Bluetooth: hci0: Debug lock is disabled
> [  278.281459] Bluetooth: hci0: Minimum firmware build 1 week 10 2014
> [  278.287890] Bluetooth: hci0: Found device firmware: intel/ibt-18-16-1.sfi
> [  280.080455] Bluetooth: hci0: Waiting for firmware download to complete
> [  280.081355] Bluetooth: hci0: Firmware loaded in 1759682 usecs
> [  280.081559] Bluetooth: hci0: Waiting for device to boot
> [  280.094388] Bluetooth: hci0: Device booted in 12666 usecs
> [  280.094524] Bluetooth: hci0: Found Intel DDC parameters:
> intel/ibt-18-16-1.ddc
> [  280.097459] Bluetooth: hci0: Applying Intel DDC parameters completed
> [  292.186182] input: Beoplay E8 (AVRCP) as /devices/virtual/input/input28
> [  505.769302] show_signal_msg: 42 callbacks suppressed
> [  505.769307] bluetoothd[2384]: segfault at 8 ip 000055cbc1e346e0 sp
> 00007ffd234a2ca8 error 4 in bluetoothd[55cbc1e09000+104000]
> [  505.769320] Code: 1f 84 00 00 00 00 00 0f 1f 00 0f b6 07 c3 66 66 2e 0f
> 1f 84 00 00 00 00 00 90 0f b6 47 01 c3 66 66 2e 0f 1f 84 00 00 00 00 00 <48>
> 8b 47 08 c3 66 66 2e 0f 1f 84 00 00 00 00 00 8d 47 ff 41 56 41
> [  574.271319] usb 1-4: USB disconnect, device number 4
> [  576.163321] Bluetooth: hci0: command 0x0c03 tx timeout
> [  577.168406] Bluetooth: hci0: HCI reset during shutdown failed
> lkocman@linux:~>

Would you please attach your bluetooth information here? eg: 
1. lsusb -d vendor:[product] -v
2. sudo hwinfo --bluetooth 
3. pactl list cards
Comment 15 Al Cho 2020-04-07 08:16:56 UTC
(In reply to Fuminobu Takeyama from comment #0)
> I have two Bluetooth headsets supporting A2DP and HSP/HFP. They works fine
> with A2DP profile. However, I cannot switch them to HSP/HFP profile to use
> their microphone.
> 
> I've tested under 3 environments
> - Leap 15.1 with a on-board Bluetooth adapter 
> - Leap 15.1 + latest Bluez and PulseAudio with a on-board Bluetooth adapter
> - Leap 15.2 with a USB dongle (CSR8510 A10)
> 

Would you please attach your USB dongle (CSR8510 A10) and on-board Bluetooth adapter bluetooth information here? include: 
1. lsusb -d vendor:[product] -v
2. sudo hwinfo --bluetooth 

> % LANG=C pactl set-card-profile bluez_card.30_A8_DB_77_4C_03
> headset_head_unit
> Failure: Input/Output error
> 
> % pactl list cards
> (SNIPPED)
> Card #1
>         Name: bluez_card.30_A8_DB_77_4C_03
>         Driver: module-bluez5-device.c
>         Owner Module: 25
>         Properties:
>                 device.description = "SBH50"
>                 device.string = "30:A8:DB:77:4C:03"
>                 device.api = "bluez"
>                 device.class = "sound"
>                 device.bus = "bluetooth"
>                 device.form_factor = "headset"
>                 bluez.path = "/org/bluez/hci0/dev_30_A8_DB_77_4C_03"
>                 bluez.class = "0x240404"
>                 bluez.alias = "SBH50"
>                 device.icon_name = "audio-headset-bluetooth"
>                 device.intended_roles = "phone"
>         Profiles:
>                 a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1,
> sources: 0, priority: 40, available: yes)
>                 headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1,
> sources: 1, priority: 30, available: no)
>                 off: オフ (sinks: 0, sources: 0, priority: 0, available: yes)
>         Active Profile: a2dp_sink
>         Ports:
>                 headset-output: Headset (priority: 0, latency offset: 0 usec)
>                         Part of profile(s): a2dp_sink, headset_head_unit
>                 headset-input: Headset (priority: 0, latency offset: 0 usec,
> not available)
>                         Part of profile(s): headset_head_unit
Comment 16 Lubos Kocman 2020-04-07 09:06:12 UTC
a cut off from lsub

Bus 001 Device 002: ID 8087:0025 Intel Corp. 
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass          224 Wireless
  bDeviceSubClass         1 Radio Frequency
  bDeviceProtocol         1 Bluetooth
  bMaxPacketSize0        64
  idVendor           0x8087 Intel Corp.
  idProduct          0x0025 
  bcdDevice            0.02
  iManufacturer           0 
  iProduct                0 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength          200
    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     0x0040  1x 64 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
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       6
      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     0x003f  1x 63 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     0x003f  1x 63 bytes
        bInterval               1
can't get device qualifier: Resource temporarily unavailable
can't get debug descriptor: Resource temporarily unavailable
Device Status:     0x0001
  Self Powered


linux:/home/lkocman # hwinfo --bluetooth 
05: USB 00.1: 11500 Bluetooth Device                            
  [Created at usb.122]
  Unique ID: xnLL.m6_ozNB5r8E
  Parent ID: k4bc.2DFUsyrieMD
  SysFS ID: /devices/pci0000:00/0000:00:14.0/usb1/1-4/1-4:1.1
  SysFS BusID: 1-4:1.1
  Hardware Class: bluetooth
  Model: "Intel Bluetooth Device"
  Hotplug: USB
  Vendor: usb 0x8087 "Intel Corp."
  Device: usb 0x0025 
  Revision: "0.02"
  Driver: "btusb"
  Driver Modules: "btusb"
  Speed: 12 Mbps
  Module Alias: "usb:v8087p0025d0002dcE0dsc01dp01icE0isc01ip01in01"
  Driver Info #0:
    Driver Status: btusb is active
    Driver Activation Cmd: "modprobe btusb"
  Config Status: cfg=new, avail=yes, need=no, active=unknown

linux:/home/lkocman # pactl list cards
Connection failure: Connection refused
pa_context_connect() failed: Connection refused
Comment 17 Lubos Kocman 2020-04-07 09:10:19 UTC
Hello Takashi

I also seemed to find root cause why is the headset(beoplay) microphone missing.
The bluetooth device was originally added (remembered) with the Leap 15.2 pulseaudio-* / bluez from Leap.

Once I removed device and re-added it by toolset from Takashi, the microphone was there and seems to be working.

So some sort of "migration/cleanup" for such headset devices might be useful.

Otherwise works for me with exception of the segfault above.
Comment 18 Fuminobu Takeyama 2020-04-12 10:59:06 UTC
Created attachment 835475 [details]
hwinfo and lsusb

@Al Please find the device information attached
Comment 19 Fuminobu Takeyama 2020-04-12 11:33:55 UTC
I've updated to 15.2 and tried pulseaudio-modules-bt.
It works like my patched package above.

Problems:
- Sometimes I need to disconnect my headset to switch between profiles
- The sampling rate is 8 kHz although SBH-50 supports 16 kHz (a.k.a HD Voice)
Comment 20 Takashi Iwai 2020-04-13 07:48:38 UTC
(In reply to Fuminobu Takeyama from comment #19)
> I've updated to 15.2 and tried pulseaudio-modules-bt.
> It works like my patched package above.
> 
> Problems:
> - Sometimes I need to disconnect my headset to switch between profiles
> - The sampling rate is 8 kHz although SBH-50 supports 16 kHz (a.k.a HD Voice)

Is this specific to pulseaudio-modules-bt, or seen also on your patched module?
Comment 21 Fuminobu Takeyama 2020-04-14 13:43:09 UTC
> Is this specific to pulseaudio-modules-bt, or seen also on your patched
> module?

It can be seen on the patched pulseaudio.

There is another patch is available at:
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/254
Comment 22 Fuminobu Takeyama 2020-04-14 13:45:47 UTC
(In reply to Fuminobu Takeyama from comment #21)
> > Is this specific to pulseaudio-modules-bt, or seen also on your patched
> > module?
> 
> It can be seen on the patched pulseaudio.

It can be seen on both the patched pulseaudio and pulseaudio-modules-bt
Comment 23 Takashi Iwai 2020-05-14 16:48:32 UTC
Nicolas noticed that the module missed AAC support via fdk-aac although the package is available on Packman.

I created a hackish patch to bind the symbols with dlopen/dlsym, as used for libavcodecs & co in this module, and he confirmed it working.

So now the package in OBS home:tiwai:bluetooth/pulseaudio-modules-bt repo got updated and include the add-on fdk-aac support.
Comment 24 Stakanov Schufter 2020-06-25 07:49:46 UTC
*** Bug 1163486 has been marked as a duplicate of this bug. ***
Comment 25 Lubos Kocman 2020-06-29 11:28:06 UTC
Hmm This happened on a clean install of Leap 15.2

alsa-plugins-pulse-1.1.5-lp152.4.1.x86_64
pulseaudio-module-gsettings-13.0-lp152.2.3.x86_64
libpulse-mainloop-glib0-13.0-lp152.2.3.x86_64
libpulse0-13.0-lp152.2.3.x86_64
pulseaudio-gdm-hooks-13.0-lp152.2.3.x86_64
pulseaudio-bash-completion-13.0-lp152.2.3.x86_64
pulseaudio-modules-bt-1.3-lp152.5.2.x86_64
pulseaudio-13.0-lp152.2.3.x86_64
mpg123-pulse-1.25.10-lp152.3.6.x86_64
pulseaudio-module-zeroconf-13.0-lp152.2.3.x86_64
pulseaudio-utils-13.0-lp152.2.3.x86_64
pulseaudio-lang-13.0-lp152.2.3.noarch
libgnome-bluetooth13-3.34.0-lp152.2.5.x86_64
gnome-bluetooth-lang-3.34.0-lp152.2.5.noarch
bluez-auto-enable-devices-5.54-lp152.4.1.noarch
bluez-cups-5.54-lp152.4.1.x86_64
libbluetooth3-5.54-lp152.4.1.x86_64
gnome-bluetooth-3.34.0-lp152.2.5.x86_64
bluez-test-5.54-lp152.4.1.x86_64
bluez-deprecated-5.54-lp152.4.1.x86_64
bluez-5.54-lp152.4.1.x86_64



...skipping...
Jun 29 13:25:24 linux.fritz.box kernel: Bluetooth: hci0: Bootloader revision 0.1 build 42 week 52 2015
Jun 29 13:25:24 linux.fritz.box kernel: Bluetooth: hci0: Device revision is 2
Jun 29 13:25:24 linux.fritz.box kernel: Bluetooth: hci0: Secure boot is enabled
Jun 29 13:25:24 linux.fritz.box kernel: Bluetooth: hci0: OTP lock is enabled
Jun 29 13:25:24 linux.fritz.box kernel: Bluetooth: hci0: API lock is enabled
Jun 29 13:25:24 linux.fritz.box kernel: Bluetooth: hci0: Debug lock is disabled
Jun 29 13:25:24 linux.fritz.box kernel: Bluetooth: hci0: Minimum firmware build 1 week 10 2014
Jun 29 13:25:24 linux.fritz.box kernel: Bluetooth: hci0: Found device firmware: intel/ibt-18-16-1.sfi
Jun 29 13:25:25 linux.fritz.box systemd[1]: Reached target Bluetooth.
-- Subject: Unit bluetooth.target has finished start-up
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit bluetooth.target has finished starting up.
-- 
-- The start-up result is done.
Jun 29 13:25:26 linux.fritz.box kernel: Bluetooth: hci0: Waiting for firmware download to complete
Jun 29 13:25:26 linux.fritz.box kernel: Bluetooth: hci0: Firmware loaded in 1659913 usecs
Jun 29 13:25:26 linux.fritz.box kernel: Bluetooth: hci0: Waiting for device to boot
Jun 29 13:25:26 linux.fritz.box kernel: Bluetooth: hci0: Device booted in 12656 usecs
Jun 29 13:25:26 linux.fritz.box kernel: Bluetooth: hci0: Found Intel DDC parameters: intel/ibt-18-16-1.ddc
Jun 29 13:25:26 linux.fritz.box kernel: Bluetooth: hci0: Applying Intel DDC parameters completed
Jun 29 13:25:34 linux.fritz.box bluetoothd[16210]: a2dp-sink profile connect failed for 00:09:A7:50:2A:C7: Protocol not available
Jun 29 13:25:34 linux.fritz.box bluetoothd[16210]: a2dp-sink profile connect failed for 00:09:A7:50:2A:C7: Protocol not available
Jun 29 13:25:35 linux.fritz.box bluetoothd[16210]: a2dp-sink profile connect failed for 00:09:A7:50:2A:C7: Protocol not available
Jun 29 13:25:35 linux.fritz.box bluetoothd[16210]: a2dp-sink profile connect failed for 00:09:A7:50:2A:C7: Protocol not available
Jun 29 13:25:36 linux.fritz.box bluetoothd[16210]: a2dp-sink profile connect failed for 00:09:A7:50:2A:C7: Protocol not available
Jun 29 13:25:36 linux.fritz.box bluetoothd[16210]: a2dp-sink profile connect failed for 00:09:A7:50:2A:C7: Protocol not available
Jun 29 13:25:37 linux.fritz.box bluetoothd[16210]: a2dp-sink profile connect failed for 00:09:A7:50:2A:C7: Protocol not available
linux:/home/lkocman # 
linux:/home/lkocman # 



What I saw as a user is disconnect right after the connect in the GNOME/Bluetooth diaglog.
Comment 26 Lubos Kocman 2020-06-29 11:29:46 UTC
Supported codecs by my earbuds (https://www.bang-olufsen.com/en/earphones/beoplay-e8-3rd-gen)

Sound Codecs
SBC, AAC codec, Aptx
Comment 27 Fuminobu Takeyama 2021-03-01 14:58:24 UTC
Finally a set of patches was merged by upstream:
https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/491
Comment 28 Takashi Iwai 2021-03-01 15:41:21 UTC
(In reply to Fuminobu Takeyama from comment #27)
> Finally a set of patches was merged by upstream:
> https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/491

Awesome, finally a step forward.

I'm building a test pulseaudio package in OBS home:tiwai:branches:multimedia:libs/pulseaudio with those backports.
Can anyone give it a try for TW?

For Leap 15.2, you might need more updates.  Some update packages are found in OBS home:tiwai:leap-15.2:update, and this test PA package is in OBS home:tiwai:leap-15.2:bluetooth-hfp repo.  A bit complex setup, and I'll merge to the former once after it's confirmed to work on TW at first.
Comment 29 Robert Munteanu 2021-03-01 16:01:10 UTC
(In reply to Takashi Iwai from comment #28)
> (In reply to Fuminobu Takeyama from comment #27)
> > Finally a set of patches was merged by upstream:
> > https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/491
> 
> Awesome, finally a step forward.
> 
> I'm building a test pulseaudio package in OBS
> home:tiwai:branches:multimedia:libs/pulseaudio with those backports.
> Can anyone give it a try for TW?
> 
> For Leap 15.2, you might need more updates.  Some update packages are found
> in OBS home:tiwai:leap-15.2:update, and this test PA package is in OBS
> home:tiwai:leap-15.2:bluetooth-hfp repo.  A bit complex setup, and I'll
> merge to the former once after it's confirmed to work on TW at first.

I am packaging the latest pulseaudio master branch locally, and that includes the patches from your home project. I see the following improvements:

- I see three sinks in gnome settings - AD2P Sink, HFP, HSP
- I get audio with HFP (although with the expected quality downgrade )
- I can record audio with HFP

What is still not working properly:

- testing the sound output is basically white noise with Gnome Settings
- I can't seem to get the HSP config to persist - it seems to change when I navigate away 

Probably the issues are all related to Gnome and not pulseaudio. I've tested with a pair of Bose HC 700.

-----

As a sidenote, what is really exciting is getting mSBC/WBS support, which is developed at https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507 and (apparently) also needs Kernel 5.11+ or 5.10.18+ ( https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507#note_821818 ).
Comment 30 Michal Koutný 2021-03-01 16:14:53 UTC
(In reply to Takashi Iwai from comment #28)
> Can anyone give it a try for TW?
I updated from 14.2-1.2 to your 14.2-8.1.
I can see now:

>	Name: bluez_card.[redacted]
>	Driver: module-bluez5-device.c
>	Owner Module: 24
>	Properties:
>		[redacted]
>		device.api = "bluez"
>		device.class = "sound"
>		device.bus = "bluetooth"
>		device.form_factor = "headset"
>		bluez.path = "/org/bluez/hci0/[redacted]"
>		bluez.class = "0x240404"
>		[redacted]
>		device.icon_name = "audio-headset-bluetooth"
>		device.intended_roles = "phone"
>	Profiles:
>		headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 30, available: yes)
>		                                                                                               ^^^
>		a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 40, available: yes)
>		off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
>	Active Profile: a2dp_sink
>	Ports:
>		headset-output: Headset (type: Headset, priority: 0, latency offset: 0 usec, available)
>			Part of profile(s): headset_head_unit, a2dp_sink
>		headset-input: Headset (type: Headset, priority: 0, latency offset: 0 usec, availability unknown)
>			Part of profile(s): headset_head_unit

Previously, the headset_head_unit was displayed as available: no. Also the
switching to it (via Gnome sound controle center) transparently switches the
profile and make the mic available (didn't work neither). The mic volume control doesn't seem to work. (The audio sink codec is still the terrible 8kHz one, but that's another issue (as mentioned in comment 29).)

Well done!
Comment 31 Takashi Iwai 2021-03-08 11:35:39 UTC
OK, let's move forward with the minimal backports.   Now I submitted my package to multimedia:libs repo.

Robert, it'd be appreciated if we can keep tracking the latest git version in some other project, meanwhile.  Hopefully the upstream will release a newer version including HFP support in near future...
Comment 32 Robert Munteanu 2021-03-08 14:57:20 UTC
(In reply to Takashi Iwai from comment #31)
> Robert, it'd be appreciated if we can keep tracking the latest git version
> in some other project, meanwhile.  Hopefully the upstream will release a
> newer version including HFP support in near future...

I've set up a repository consisting of:

- the latest pulseaudio master branch
- the  WBS/mSBC patch set from https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507

What this gets you is good quality audio for conference calls when compared to the default SBC codec. It runs well enough for me, if anyone else is interested feel free to use my home repo:

$ sudo zypper ar --refresh https://download.opensuse.org/repositories/home:/robert_munteanu:/branches:/openSUSE:/Factory/openSUSE_Tumbleweed pulse-bluetooth
$ sudo zypper dup --from pulse-bluetooth --allow-vendor-change

You should see most of your pulse packages switching vendor

  openSUSE -> obs://build.opensuse.org/home:robert_munteanu

After this, it's time to test:

- logout/restart
- connect bluetooth headset
- run pavucontrol
- in the configuration tab, for the headset, select the 'Handsfree Head Unit (HFP)' profile
	- note: for my headphones being connected to the phone and laptop at the same time lead to the profile being unavailable, so make sure to only connect the headphones to a single device during testing.

To double-check, run `pactl list cards | grep bluetooth.codec'. The output should be 

    bluetooth.codec = "mSBC"

At this point you should be good to go. Enjoy!

For problems related to the pulseaudio functionality itself please comment on https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/507. If you have other problems related to the packages themselves let me know and I'll try to help.
Comment 33 Fuminobu Takeyama 2021-03-11 13:36:31 UTC
I tried pulsaudio from multimedia:libs and some packages from home:tiwai:leap-15.2:update on Leap 15.2. HFP of SBH-50 is now working.

I tested with another device, ADV. AP AIR. According to `pactl list`, it provides three profiles:

- HSP (available: no)
- A2DP
- HFP

Although HSP is not available, A2DP and HFP looks working fine.
Comment 34 Frederic Crozat 2021-03-11 15:04:37 UTC
Tested on SLE15 SP2 + the packages from home:tiwai:leap-15.2:update

Bose QC Earbuds:
- works A2DP
- headset mode works in HFP mode
- HSP mode doesn't work (not possible to switch to it)

Sony WH-1000XM2:
- works A2DP
- headset mode works in HFP mode
- HSP mode doesn't work (not possible to switch to it)
Comment 36 Takashi Iwai 2022-02-08 10:21:12 UTC
PA on Leap 15.3 had already improved support for BT headset.
Let's close.