Ubuntu – How to keep the audio profile at A2DP while using a mic with Bluetooth headset? (Push-to-talk)

17.10bashbluetoothmicrophonesound

I have a CEL-TEC F5A headset.
The spec says:

Bluetooth 4.0, profiles: Headset, Hands free, A2DP, AVRCP/HSP/HFP

It plays nicely with High Fidelity Playback (A2DP sink) profile.

When I want to switch audio input to the headset's microphone, the output profile automatically changes to Headset Head Unit (HFS/HFP) and the quality is terrible – like 8bit sound or something. When I switch it back to A2DP, the input is back to desktop mic.

I've read few of other questions and seems A2DP is expected not to support input, right? But the HFP part in HFS/HFP is High Fidelity Playback I guess? That sounds like it could work as a headset and still not sound like 1950's phone.

How could I simplify switching between the profiles so that it is HFS/HFP when I talk and A2DP when I listen? E.g. as a push-to-talk.

Ubuntu 17.10, no sound customization IIRC, everything latest.
https://www.kabelmanie.cz/cel-tec-f5a-active-noise-bluetooth-stereo-sluchatka-s-mikrofonem/

My output:

$ pactl list cards
Card #0
        Name: alsa_card.pci-0000_00_03.0
...

Card #4
        Name: bluez_card.00_19_5D_25_6F_6C
        Driver: module-bluez5-device.c
        Owner Module: 30
        Properties:
                device.description = "F5A"
                device.string = "00:19:5D:25:6F:6C"
                device.api = "bluez"
                device.class = "sound"
                device.bus = "bluetooth"
                device.form_factor = "headset"
                bluez.path = "/org/bluez/hci0/dev_00_19_5D_25_6F_6C"
                bluez.class = "0x240404"
                bluez.alias = "F5A"
                device.icon_name = "audio-headset-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: yes)
                off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
        Active Profile: a2dp_sink
        Ports:
                headset-output: Headset (priority: 0, latency offset: 0 usec, available)
                        Part of profile(s): a2dp_sink, headset_head_unit
                headset-input: Headset (priority: 0, latency offset: 0 usec)
                        Part of profile(s): headset_head_unit

The problem here is not that the microphone does not work, but rather that the audio quality worsens when it is activated.

Best Answer

Ondra, there is a very long pulse audio merge request discussion that contains most of the information.

tl;dr; to get things working pulse audio, bluez and kernel need to be updated (not trivially). As well a separate daemon hsphfpd is necessary.

Kernel updates are not progressing and user input to maintainers would be helpful in pushing things forward. Think about providing such. See here.

Without the kernel patches, using headphones' mic leads to terrible audio quality (HSP/HFP mode of operation).

But there is chance that only Pulse patches (and support from your headphones) can enable A2DP bi-directional audio which should be alright for most purposes.

And that patch is progressing well at the moment. More feedback on it shouldn't hurt.

Update: THings in above mentioned pull request escalated very quickly and seems like PulseAudio may never implement proper bluetooth support. Lets hope for Pipewire which already has some patches.