Bluetooth fix for December update

Hi Sam !

Made a fresh installation (latest osmc 2018-02-01) with the git-version of a2dp-app-osmc, and here is my dicovering.
Firstly i disabled onboard bt (dtoverlay=pi3-disable-bt), then cloned git and made package,
right after install a2dp-app-osmc i have:

osmc@pi:~$ systemctl status pulseaudio
● pulseaudio.service - Pulse Audio
   Loaded: loaded (/lib/systemd/system/pulseaudio.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2018-03-12 22:32:17 MSK; 3min 24s ago
 Main PID: 952 (pulseaudio)
   CGroup: /system.slice/pulseaudio.service
           └─952 /usr/bin/pulseaudio --system --disallow-exit --disable-shm --realtime --no-cpu-limit

system pulse unit started, but:

osmc@pi:~$ ps axwu|grep pulse
osmc       362  0.5  0.9  90120  7420 ?        Sl   22:29   0:01 /usr/bin/pulseaudio --start --log-target=syslog
pulse      952  0.2  0.9  99484  7512 ?        S<sl 22:32   0:00 /usr/bin/pulseaudio --system --disallow-exit --disable-shm --realtime --no-cpu-limit

we also have a user instance, thats why you can’t use bt headset.
In my case, i can connect headset (via kodi GUI):

osmc@pi:~$ sudo bluetoothctl
[NEW] Controller 00:1A:7D:DA:71:11 pi [default]
[NEW] Device 00:11:67:11:4C:EE BT-1005
[BT-1005]# paired-devices
Device 00:11:67:11:4C:EE BT-1005

but:

osmc@pi:~$ pactl list short cards
0 alsa_card.platform-soc_audio module-alsa-card.c

This is because the headset connected to the system instance of pulseaudio,
kodi (as osmc user) connected to the user instance.

So, what we need to do now:
as osmc user disable pulseaudio user unit:

osmc@pi:~$ systemctl --user disable pulseaudio

and disable autostart server in /etc/pulse/client.conf:

autospawn = no

After reboot for clean start:

osmc@pi:~$ ps axwu|grep pulse
pulse 192 5.7 1.0 108924 8156 ? S<sl 22:57 2:57 /usr/bin/pulseaudio --system --disallow-exit --disable-shm --realtime --no-cpu-limit

Now connect headset:

osmc@pi:~$ pactl list short cards
0 alsa_card.platform-soc_audio module-alsa-card.c
2 bluez_card.00_11_67_11_4C_EE module-bluez5-device.c

Switch pulse in kodi and listen audio from headset. But in my case default card profile
not a2dp:

osmc@pi:~$ pactl list cards

Card #1
Name: bluez_card.00_11_67_11_4C_EE
Driver: module-bluez5-device.c
Owner Module: 16
Properties:
device.description = “BT-1005”
device.string = “00:11:67:11:4C:EE”
device.api = “bluez”
device.class = “sound”
device.bus = “bluetooth”
device.form_factor = “speaker”
bluez.path = “/org/bluez/hci0/dev_00_11_67_11_4C_EE”
bluez.class = “0x240414”
bluez.alias = “BT-1005”
device.icon_name = “audio-speakers-bluetooth”
Profiles:
headset_head_unit: Headset Head Unit (HSP/HFP) (sinks: 1, sources: 1, priority: 20, available: yes)
a2dp_sink: High Fidelity Playback (A2DP Sink) (sinks: 1, sources: 0, priority: 10, available: yes)
off: Off (sinks: 0, sources: 0, priority: 0, available: yes)
Active Profile: headset_head_unit
Ports:
speaker-output: Speaker (priority: 0, latency offset: 0 usec)
Part of profile(s): headset_head_unit, a2dp_sink
speaker-input: Bluetooth Input (priority: 0, latency offset: 0 usec)
Part of profile(s): headset_head_unit

I think this is my bt adapter feature, switch to a2dp:

osmc@pi:~$ pactl set-card-profile bluez_card.00_11_67_11_4C_EE a2dp_sink

Personally, I’m using a python script that tracks dbus events and runs this command when the bt headset is connected. It is possible, to add a module to system.pa: module-card-restore
in this case the pulseaudio will restore the profile of the bt card when connected, in this way we only need to set the card profile once.

Tomorrow i try to make changes in postint and client.conf and make a new fresh install.

4 Likes